📅  最后修改于: 2022-03-11 14:52:05.249000             🧑  作者: Mango
public class NewClass4 {
public static void main(String[] args)
{
HashMapmap=new HashMap();
map.put(1, 50);
map.put(2, 60);
map.put(3, 30);
map.put(4, 60);
map.put(5, 60);
int maxValueInMap=(Collections.max(map.values())); // This will return max value in the Hashmap
for (Entry entry : map.entrySet()) { // Itrate through hashmap
if (entry.getValue()==maxValueInMap) {
System.out.println(entry.getKey()); // Print the key with max value
}
}
}
}