Get minvalue of a Map(Key,Double)

前端 未结 9 1949
一个人的身影
一个人的身影 2020-12-05 07:08

Is there a method (maybe with Google Collections) to obtain the min value of a Map(Key, Double)?

In the traditional way, I would have to sort the map ac

9条回答
  •  遥遥无期
    2020-12-05 07:53

    Java8 One-Liner

    Key key = Collections.min(map.entrySet(), Map.Entry.comparingByValue()).getKey()
    

提交回复
热议问题