View Single Post
Old 05-01-2003, 06:17 PM   #1 (permalink)
English
I donated a lot!I donated a lot!I donated a lot!
First Lieutenant
 
Join Date: Oct 2002
Location: England
Posts: 1,681
English is on a distinguished road
Default Java linked list

Jesus, any1 do java? Im used to using pointers. Im trying to do a linked list, but I cant get my head around it.

Here is my code to return the number of items in the list.
Code:
public int cardinality()
          {
            int count = 0;
            word temp = this.FirstWord;

             do
             {
                count++;
                temp = temp.returnNext();
             }while (temp!=null);


            return count;
          };
The line
Code:
temp = temp.returnNext();
Seems to be messing up the list, as it sets whats in temp, to equal whats in the next item. Where as I just want to point to that new item. Yes?

Im used to using C, where u can use pointers for everything. Does any1 know a way of doing it?

Morat, i think u program, help me.
English is offline   Reply With Quote