This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Java in General and the fly likes Hashtable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hashtable" Watch "Hashtable" New topic


suman deb
Ranch Hand

Joined: Jul 14, 2005
Posts: 54
By default, Hashtable is unordered. Then, how can you retrieve Hashtable elements in the same order as they are put inside?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15047

If you really want to do this with Hashtable, you'd have to implement a mechanism yourself to remember the order in which the entries were inserted into the Hashtable.

But you'd better use LinkedHashMap, which already does this for you. Look it up in the API documentation.
[ August 23, 2005: Message edited by: Jesper de Jong ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Hashtable
It's not a secret anymore!