aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
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
Author

Implementing Hashtable and linked list in java

pandu ranga
Greenhorn

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?

Regards
Pandu
Nitesh Kant
Bartender

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
Greenhorn

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.

Rgrds
Chirag
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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: http://aspose.com/file-tools
 
subject: Implementing Hashtable and linked list in java