This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Hashtable showing irregular results Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hashtable showing irregular results" Watch "Hashtable showing irregular results" New topic
Author

Hashtable showing irregular results

Madhu Kaparapu
Ranch Hand

Joined: Jul 04, 2005
Posts: 35
Hi all,
i've encountered an strange result while working with hashtable.
I've noticed that the elements are not displyed in the order they were added to the table.
Can anybody plz let me know what meight be the reason?
Thanks all,
Madhu


Regards,
Madhu Kaparapu.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Hashtable does not maintain the order of objects added to it.
If order is important, use LinkedHashMap
[ July 07, 2005: Message edited by: Mani Ram ]

Mani
Quaerendo Invenietis
Sunil Phani Manne
Greenhorn

Joined: Jun 20, 2005
Posts: 10
It is its intended behaviour. A Hashtable doesnt guarantee u the order. Read about collections framework in java for more details.

Regards,
Sunil Phani Manne
 
jQuery in Action, 2nd edition
 
subject: Hashtable showing irregular results