I am trying to build a simple program that in essence will return the key associated to the highest value in a nested Map. For example (below numbers are just an example, they are not real).
public class MultiValueMap {
public static void main(String[] args) {
Map<String, HashMap<String, Integer>> singers = new HashMap<>();
singers.put("Elvis", new HashMap<>());
singers.get("Elvis").put("All Shook up", 8);
singers.get("Elvis").put("Don't be Cruel", 5);
singers.get("Elvis").put("Viva las Vegas", 3);
}
}
The idea here is to get either the top song or lowest rated song. The program should return for example "All Shook Up" if I want the top rated song.
Any ideas on how to accomplish this?