Wednesday, June 29, 2005

HashMap maladies...

been working with hashmaps for quite a long time now... but one thing escapes me...Consider the following snippet to display the contemts of a HashMap in a sequential manner.
 //temp2 is a hashmap
Set set2=temp2.entrySet();
Iterator iHash2=set2.iterator();

Map.Entry me2= (Map.Entry);
well if u understand the code ...( i dont see any issues here) on
I printed the order in which the elements were entered in the HashMap and later printed the hashMap using the above algorithm... both are different.... Any idea why??

1 comment:

  1. Well am replying to myself after one year...
    I was a moron and did not understand HashMap which is maintained as a balanced red black tree... obviously the ordering will be lost.