I have a hashmap storing the number of occurrences of character in a text. I am trying to print out the top 3 occurrences, but it is printing incorrectly.
int max = 1000000000;
for (int i = 1; i <= 3; i++) {
for (Character key : list.keySet()) {
if (list.get(key) < max) {
max = list.get(key);
System.out.println(i + ": " + key + " " + list.get(key));
break;
}
}
}