When we output the values of a simple hashtable why it's values output in decremented order of it's key?
And how can I output in incremental order?
Hashtable<Integer, String> htable = new Hashtable<>();
htable.put(100, "Dil");
htable.put(200, "Vidu");
htable.put(300, "Apeksha");
htable.put(400, "Akalpa");
htable.put(500, "Akash");
for (Map.Entry entry : htable.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue() + " : " + entry.hashCode());
}
Output
500 : Akash : 63312920
400 : Akalpa : 1962708790
300 : Apeksha : 861238907
200 : Vidu : 2666092
100 : Dil : 68611
Also Can you please explain what actually hashcode is? Is that a random number set to make each result is unique?
Thank you.