Two Laptop Bag
The moose likes Java in General and the fly likes Sorting hashtable entries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Sorting hashtable entries" Watch "Sorting hashtable entries" New topic

Sorting hashtable entries


Joined: May 21, 2001
Posts: 7
Is there any way i can retrive the entries from the Hashtable in the sequence that i put them in. Not using the key to get the value, just getting the next element until i reach the end of the Hashtable. The order somehow seems to be different from the order in which i put the data in.
Aj Manch
Ranch Hand

Joined: May 07, 2001
Posts: 50
Hashtable doesn't store the order of insertion of its elements. Take a look at Vector or TreeMap instead.
Mark Herschberg

Joined: Dec 04, 2000
Posts: 6037
Alternatively, you could extend the class and add in the functionality through the overridden put method.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: Sorting hashtable entries
It's not a secret anymore!