This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Implementation of data structure(Link List) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Implementation of data structure(Link List)" Watch "Implementation of data structure(Link List)" New topic
Author

Implementation of data structure(Link List)

Rubbal Bhusri
Ranch Hand

Joined: Dec 30, 2010
Posts: 71
Can we Implement Link List in java as we do in C or C++ language ?
e.g.

Struct node{

int value;
node * link;

}*start;

Since there are no pointers in java, so how do we implement Link List in java ?
Saket Kumar Sinha
Ranch Hand

Joined: Aug 04, 2011
Posts: 31



That may help
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3615
    
  14

Java uses references instead of pointers.

Just give one node a reference to the next node.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4369
    
    8

References in Java are not as different to pointers in C++ as some people would have you believe, and they'll do what you want here (as Saket indicates). The real difference is that you can't do pointer arithmetic with them.
Kemal Sokolovic
Bartender

Joined: Jun 19, 2010
Posts: 825
    
    5

Check this topic, it contains some guidelines on how to develop doubly linked list, you may find it helpful.


The quieter you are, the more you are able to hear.
Rubbal Bhusri
Ranch Hand

Joined: Dec 30, 2010
Posts: 71
Please give me a link where i can study about references more.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38436
    
  23
Let’s try googling: I found 1 2 3 (maybe less good than the other two). There were lots more hits. I hope those hits are useful for you.
 
 
subject: Implementation of data structure(Link List)