linked list of linked lists in java
ok, so i have a data structure that is a linked list of linked lists, both using the java collection "LinkedList"... it is supposed to fucntion as a queue of integer linked lists...
LinkedList llq=new LinkedList();
i add objects on to the queue "llq" by using the foll stmts:
LinkedList llstate = new LinkedList();
Integer xx= new Integer(x)
llstate.addLast(xx);
llq.addLast(llstate);
now, when i want to retreive the first queue of integers from the queue llq, i say:
LinkedList p = (LinkedList)llq.getFirst();
this works fine, and when llq= [ [0],[1]], i do get the desired output of p=[0] upon executing this stmt. and since i only "get" the first item of llq, and not "remove" it, i assume that it is still on the queue llq.
i go on to perform some manipulations on p, removing all its elements till p=[ ]. but now, i want it to go back to containing the first element of llq, ie [0]. so i say again:
p=(LinkedList)llq.getFirst();
however, here lies the problem: even after executing this stmt, p still is an empty list, ie [ ]. i figure there must be some referencing going on, and it may be a problem with that, that is, maybe p is a reference to the first element, and it actually changes the contents of llq when we manipulate the contents of p. but this does not seem to be true. when i output both p and q after this stmt, i get p=[ ](dunno why), and q=[[0],[1]] (as i expected)
i even tried using an entirely diff variable to retreive this [0], the first element on llq, but it simply does not seem to work.
LinkedList r=(LinkedList) llq.getFirst();
this last stmt also gives me an output r=[ ]!!! wats up wit that? seriously, i am getting outputs r(or p)= [ ] when i have JUSTchecked llq=[[0],[1]], AND i have assigned r to contain the first element of llq! i am thoroughly confused and would greatly appreciate if somebody could clear up this mystery for me!!!
Thanx!

