java.util.Hashtable
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   innum_onenu
Posted On:   Wednesday, May 23, 2001 06:29 AM

If am using a Hashtable and filling it with some key-value pairs using the put method in a particular order, then when I retrieve the keys with .keys methods I get a enumeration of keys.
Now when I loop the eneumeration with hasMoreElements the key-value returned are in a different order from the order i entered into it..
What could be problem?
Thanks!

Re: java.util.Hashtable

Posted By:   John_Zukowski  
Posted On:   Wednesday, May 23, 2001 07:19 AM

The 1.4 JDK will add a new map implementation that preserves key-value insertion order. Until then, you're on your own to maintain insertion order.

Re: java.util.Hashtable

Posted By:   Luigi_Viggiano  
Posted On:   Wednesday, May 23, 2001 06:52 AM

Hashtable doesn't guarantee order: it uses an hash function to store objects and order is lost, use a TreeMap instead and define your own sorting method using your own Comparator.
About | Sitemap | Contact