File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Implementing Hashtable and linked list in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Implementing Hashtable and linked list in java" Watch "Implementing Hashtable and linked list in java" New topic

Implementing Hashtable and linked list in java

pandu ranga

Joined: Oct 22, 2007
Posts: 23
Hi ,

I want to implement the Linked list, hash table functionality in java without using the standard API'S assuming they are not present.How Can I achieve this?

Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

Firstly, why do you want to do it?
Have you tried something? Where is it that you are stuck?

apigee, a better way to API!
Chirag Mehta

Joined: May 09, 2007
Posts: 3
I suppose the requirement is that you don't want to use standard API i.e. you don't want to use java.util package and want to create a linklist or want to implement hashtable.

You can try 2 things
1. Use arrays but that need more memory management for an unbounded list.
2. Create a structure using innerclass that can hold the reference of objects.

Ask for further pointer if required.

Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

Usually, a linked list internally has a structure that stores two or three references: that to the data stored, that to the successor (next node) and optionally that to the previous node.

That's exactly how java.util.LinkedList have done it, with one major difference. While most linked lists are actually that - linked lists, i.e. a chain of nodes, java.util.LinkedList uses a chain structure. It has a special node that connects the first and last node together. Please note that this is mostly for performance issues, because you can now go both ways when traversing the list, choosing the shortest path to any node.

How To Ask Questions How To Answer Questions
Surya Kant
Ranch Hand

Joined: Mar 29, 2005
Posts: 104
Hi Chirag,
Can you please elaborate more on how to go about implementing linked list without using data structures?I am really in need of that implementation.
Please help me..
I agree. Here's the link:
subject: Implementing Hashtable and linked list in java
jQuery in Action, 3rd edition