I would like to change the elements in my LinkedHashMap in the reverse order. Something like this:
public static void main(String[] args){
Map<String, Integer> map = new LinkedHashMap<>();
map.put("Hello", 2);
map.put("World", 1);
reverse(map);
System.out.println(map);// {Wordl=1, Hello=2}
}
public static void reverse(Map<String, Integer> map){
// Reverse my map...
}
But I did not find anything that could help me to do this. Can someone suggest how this can be solved? Thank.