Rathi, Let me explain it to you more detail. When I said that the order of the entries in a HashMap can't be guaranteed will remain the same over the time, it means that whenever an entry is added or removed from a HashMap, the order of the entries inside it may change. In your case that the order are the opposite, it's just a coincident.
Although I it is tough for me to beleive that it is just am coincident , because coincident doesn't happen everytime . You can try ... I think their is some confusion because of Set ... but not sure ...
OK but I agreed , So can you tell me , what should I do , what my requirement is , I have to retrieve the values of Map one by one ( only values ) in a order , I have entered . I am using j2se 1.3 so can't use LinkedHashMap .
Exactly, HashMap is an unordered collection. You can either use LinkedHashMap (new in JDK 1.4) which maintains the elements in the same order in which they were added or TreeMap which will order the values using the natural ordering of their keys. Since your keys are Integers, this will work without any more work on your part since you want them in numeric order.
If only the values you are concerning of, why don't you just use List instead of Map? But if you still want to use Map, it has values() method that return a Collection.
ps. Rathi, if you have a problem with Java (or other languages), please try to get the solution first by reading the API documentation before asking for help form other people. This also true for other languages. [ February 15, 2005: Message edited by: Yosi Hendarsjah ]
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!