This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "hashtable in java" Watch "hashtable in java" New topic
Author

hashtable in java

vijayapriya thirumurugan
Greenhorn

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
Sheriff

Joined: Oct 27, 2005
Posts: 20080
    
  30

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).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: hashtable in java
 
It's not a secret anymore!