aspose file tools*
The moose likes Beginning Java and the fly likes Linked List Simple question?!? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Linked List Simple question?!?" Watch "Linked List Simple question?!?" New topic
Author

Linked List Simple question?!?

Nadine Ernest
Greenhorn

Joined: Dec 10, 2008
Posts: 27
so im a bit confused about the




what does it mean?
does it mean the previous of the current and then the next of the previous of the previous current which is the current itself.............i know thats wrong soooo how do i not confuse it again"???


and explain please this one too

???

thanks in advance...


What Doesn't Kill You, Makes You Stronger!
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi Nadine,

Actually, you explained it correctly. If "current", "previous", and "next" are all links to nodes in a linked list, and each node has members named "previous" and "next", and "current" points to some node of interest that is not the very first node in the list, then "current.previous.next" would be the node after the node before the current node -- or the current node itself. Similarly, if "first" points to some node which is not the last node in the list, then "first.next.previous" would be the node before the node after first -- i.e., first.


[Jess in Action][AskingGoodQuestions]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11411
    
  16

the dot operators go left to right. so, the first one is saying

take the current object, get its previous reference, and then take THAT things next reference.

Assuming current points to the nth object, current.previous would give you the (n-1)th object. You then get the next reference from the (n-1)th, which should give you the nth.

your second example is similar. first should point to the 1st object. you then get the reference to the next object, which would give you the 2nd. you then get the previous reference from the 2nd, putting you back at the 1st.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Nadine Ernest
Greenhorn

Joined: Dec 10, 2008
Posts: 27
Ernest Friedmann Hill : thank you soo much ,, you made it really simple for me to understand it!! its an honor to have you here to help us in our problems!!

Fred Rosenberger : thanks ,,, i got it now!!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Linked List Simple question?!?