GeeCON Prague 2014*
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
Author

Sorting hashtable entries

Preetham
Greenhorn

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
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Alternatively, you could extend the class and add in the functionality through the overridden put method.
--Mark
hershey@vaultus.com
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
"Preetham",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . 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.
Thanks.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
GeeCON Prague 2014
 
subject: Sorting hashtable entries