File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Implementation of data structure(Link List)" Watch "Implementation of data structure(Link List)" New topic

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 ?

Struct node{

int value;
node * link;


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: 32

That may help
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4200

Java uses references instead of pointers.

Just give one node a reference to the next node.

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

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

Joined: Jun 19, 2010
Posts: 825

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

Joined: Oct 13, 2005
Posts: 45302
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.
I agree. Here's the link:
subject: Implementation of data structure(Link List)
It's not a secret anymore!