jQuery in Action, 2nd edition*
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 Android Security Essentials Live Lessons this week in the Android 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: 31

That may help
Stephan van Hulst

Joined: Sep 20, 2010
Posts: 3600

Java uses references instead of pointers.

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

Joined: Apr 06, 2010
Posts: 4344

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: 38045
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: http://aspose.com/file-tools
subject: Implementation of data structure(Link List)
Similar Threads
Tree Structure + Depth First Traversal?
malloc undeclared error in simple linked list
implementing linked list using core java
Basic data structure and java.util package
doubly linked list