wood burning stoves*
The moose likes Beginning Java and the fly likes hashtable in java 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 » Beginning Java
Bookmark "hashtable in java" Watch "hashtable in java" New topic

hashtable in java

vijayapriya thirumurugan

Joined: Apr 03, 2009
Posts: 16

hello sir,

I have hashtable consists of keys with their corresponding values. While entering the values in hashtable it's in ascending order. but in printing statement the hashtable comes in descending order. I used Enumeration to print the values. What's the mechanism behind that. can you explain me. Because i need in ascending order only. i'm waiting..
Rob Spoor

Joined: Oct 27, 2005
Posts: 19655

Hashtable and HashMap don't keep order at all. If you need order you should check out TreeMap (user defined order based on the keys) or LinkedHashMap (order based on insertion order / access order).

How To Ask Questions How To Answer Questions
It is sorta covered in the JavaRanch Style Guide.
subject: hashtable in java
Similar Threads
Sorting HashTable by values
how can be retrieve from any collection into our own order?
It's a bird, it's a plane, no, it's a ... bubble sort?
static variables in JavaScript or equivalent ?
Collection Class Implementation Features (Contributions Requested)