Battlefield Nation Forums  

Go Back   Battlefield Nation Forums > Other > Off-topic


You are currently viewing our boards as a guest which means you can view posts, but can't make any of your own.

Registration is easy and absolutely free, so why not join the longest-running Battlefield community on the web!

Off-topic Anything not related to the Battlefield series. Well, almost...

Reply
 
Thread Tools
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
Old 05-01-2003, 07:19 PM   #2 (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

Forget it, ive sorted it....

I forgot to set the last element of the list to the new element. The list wasnt growing.

1 line of code == 2 hours of pulling ur hair out.

Stay away from programming.
English is offline   Reply With Quote
Reply

« Previous Thread | Next Thread »

Thread Tools


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Forum Jump


All times are GMT. The time now is 09:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC1