public static void main(String[] args) { Mapmap = new HashMap<>(); map.put("A",5); map.put("B",1); map.put("C",6); String collect = map.entrySet().stream() .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) .map(Map.Entry::getKey) .collect(Collectors.joining(",")); System.out.println(collect); }
public static void main(String[] args) { Mapmap = new HashMap<>(); map.put("A",5); map.put("B",1); map.put("C",6); map.put("D",1); Map >> collect = map.entrySet().stream() .collect(Collectors.groupingBy(Map.Entry::getValue)); }
public static void main(String[] args) { Mapmap = new HashMap<>(); map.put("A",5); map.put("B",1); map.put("C",6); map.put("D",1); Map collect = map.entrySet().stream() .collect(Collectors.groupingBy(Map.Entry::getValue, Collectors.counting())); }
public static void main(String[] args) { MapOptionalmap = new HashMap<>(); map.put("A",5); map.put("B",1); map.put("C",6); map.put("D",1); Map > collect = map.entrySet().stream() .collect(Collectors.groupingBy(Map.Entry::getValue, Collectors.mapping(Map.Entry::getKey, Collectors.toSet()))); }
public static void main(String[] args) { boolean present = Optional.ofNullable(null).isPresent(); String o = Optional.ofNullable("B").filter("A"::equals).orElse("***"); System.out.println(present); System.out.println(o); }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)