public static void main(String[] args) {
List list = new ArrayList<>();
list.add(Student.builder().stuNo("23444").name("test").build());
list.add(Student.builder().stuNo("11111").name("test2").build());
list.add(Student.builder().stuNo("6666").name("test3").build());
list.add(Student.builder().stuNo("11111").name("test5").build());
// 方式一:单属性去重
List unique1 = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Student::getName))), ArrayList::new));
// 方式一:多属性去重
List unique1 = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Student::getName).thenComparing(Test::getStuNo))), ArrayList::new));
}
public static Predicate distinctByKey(Function super T, ?> keyExtractor) {
Map