title: Java - Select the Second value in hashmap
body: <p>Here is My hashmap:</p>
  
  <pre><code>            if (m1.get(image.getRGB(x, y)) == null) {
              m1.put(image.getRGB(x, y), 1);
  
          } else {
              int newValue = Integer.valueOf(String.valueOf(m1.get(image.getRGB(x, y))));
              newValue++;
              m1.put(image.getRGB(x, y), newValue);
  
          }
  </code></pre>
  
  <p>then I print it like this:</p>
  
  <pre><code>for (Object key : m1.keySet()) {
          Color temp = new Color((int) key);
          int r = temp.getRed();
          int g = temp.getGreen();
          int b = temp.getBlue();
          System.out.println("r: " + r + " G: " + g + " B: " + b+ "\t\tValue: " + m1.get(key));
  
      }
  </code></pre>
  
  <p>How can I select the second value (second max in hashmap) of my hashmap save its value in another variable?</p>