Get the key for the maximum value in a HashMap using Collections [duplicate]
问题 This question already has answers here : Finding Key associated with max Value in a Java Map (16 answers) Closed 4 years ago . I have a HashMap of arbitrary objects, with Double values as the value: HashMap<MyObject, Double> myMap = new HashMap<>(); . I can get the maximum Double value in the HashMap using Collections.max(myMap.values()); but I need to get the corresponding key for that value. Is there an easy way to do this with the Collections API it or would I need an iterator? I've