// 根据name去重
List unique = persons.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Person::getName))), ArrayList::new)
);
Original: https://www.cnblogs.com/zhuzhen/p/14048078.html
Author: 十七年蝉
Title: Java 使用Stream处理List对象去重
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/620330/
转载文章受原作者版权保护。转载请注明原作者出处!