List<Integer> collect = Arrays.asList(1,2,3,4,5,5,6,6,7,7,7,8,8).stream()
.collect(Collectors.toMap(Function.identity(), v -> 1, Integer::sum))
.entrySet()
.stream()
.filter(e -> e.getValue() ==1 )
.map(Map.Entry::getKey)
.collect(Collectors.toList());
collect.stream().forEach(System.out::println);
输出1,2,3,4
数组中有重复的数据全部去掉
于 2022-02-09 10:23:51 首次发布