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 thought about getting the position of the max value and then querying the HashMap for that position and get the key but I'm not sure how to do that.
EDIT: I can change the type from a HashMap to something else if necessary, but those two types (Object and Double) need to stay the same.