Map<String, Integer> map = new HashMap<>(); map.put("o", 4); map.put("t", 2); map.put("s", 1); List<Map.Entry<String, Integer>> list = new ArrayList(map.entrySet()); // list.sort((o1, o2) -> (o1.getValue() - o2.getValue())); list.sort(Comparator.comparingInt(Map.Entry::getValue)); String key1 = list.get(0).getKey();
获取map中最小的value值的key
最新推荐文章于 2023-05-25 10:24:39 发布