Hi I have the following HashMap
HashMap<String, Integer> normalised = new HashMap<String, Integer>();
and would like to print out the highest value in the map and its associated key.
Could anyone help I tried using the following code to no avail
String maxKey=null;
int maxValue = Interger.MIN_VALUE;
for(Map.Entry<String,Integer> entry : normalised.entrySet()) {
if(entry.getValue() > maxValue) {
maxValue = entry.getValue();
maxKey = entry.getKey();
}
}
Can someone guide to as where I am going wrong
Thanks in advance