我将按值分组并将值存储到TreeMap中,以便对值进行排序,然后通过获取下一个最后一个条目来获得最大值:
Stream.of(1, 3, 5, 3, 2, 3, 5) .collect(groupingBy(Function.identity(), TreeMap::new, toList())) .lastEntry() .getValue() .forEach(System.out::println);
输出:
55

我将按值分组并将值存储到TreeMap中,以便对值进行排序,然后通过获取下一个最后一个条目来获得最大值:
Stream.of(1, 3, 5, 3, 2, 3, 5) .collect(groupingBy(Function.identity(), TreeMap::new, toList())) .lastEntry() .getValue() .forEach(System.out::println);
输出:
55