title: Get Hashmap Top 3 Keys
body: <p>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.</p>
  
  <pre><code>int max = 1000000000;
  for (int i = 1; i &lt;= 3; i++) {
      for (Character key : list.keySet()) {
          if (list.get(key) &lt; max) {
              max = list.get(key);
              System.out.println(i + ": " + key + " " + list.get(key));
              break;
          }
      }
  }
  </code></pre>