I am trying this for some hour but not finding any best approach to achieve iteration of hashmap in reverse order, this is the hashmap I have.
Map
TreeMap map = new TreeMap(); map.put(1, "abc1"); map.put(2, "abc2"); map.put(3, "abc3"); NavigableMap nmap = map.descendingMap(); for (NavigableMap.Entry entry : nmap.entrySet()) { System.out.println("Key : " + entry.getKey() + " Value : " + entry.getValue()); }
An implementation of NPE idea.