Here is My hashmap:
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);
}
then I print it like this:
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));
}
How can I select the second value (second max in hashmap) of my hashmap save its value in another variable?