This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hashtable" Watch "Hashtable" New topic
Author

Hashtable

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: 14074
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
 
Don't get me started about those stupid light bulbs.
 
subject: Hashtable
 
Similar Threads
Hashtables are synchronized...
Collections
HashMap or HashTable
Hashtable casting error
Collection- Fast Retrieval