Possible Duplicate:
Iterating through a LinkedHashMap in reverse order
How to traverse Linked Hash Map in a reverse order? Is there any predefined method in map to do that?
I’m creating it as follows:
LinkedHashMap<Integer, String> map = new LinkedHashMap<Integer,String>();
map.put(1, "one");
map.put(2, "two");
map.put(3, "three");
Not really pretty and at the cost of a copy of the entry set, which if your map has a significant number of entries might be a problem.
The excellant Guava library have a
[List.reverse(List<>)][2]that would allow you to use the Java 5 for each style loop rather than the indexed loop: