获取map最小值对应的key(jdk1.8)
public static void main(String[] args) {
Map<String, Long> map = new HashMap<>();
map.put("哈哈", 1L);
map.put("呵呵", 1L);
map.put("嘿嘿", 3L);
Long value= map.values().stream().sorted().findFirst().get();
List<String> collect = map.entrySet()
.stream()
.filter(kvEntry -> Objects.equals(kvEntry.getValue(), value))
.map(Map.Entry::getKey)
.collect(Collectors.toList());
//若值有重复的,则collect集合中有多个key,按照业务需求自行取值
System.out.println(collect.get(0));
}