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 Sorting hashtable entries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
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
It is sorta covered in the JavaRanch Style Guide.
subject: Sorting hashtable entries
It's not a secret anymore!