为什么 copy 下来运行就报错,空指针,不清楚在网上的例子是怎么跑的
studentList = studentList.stream().collect(
Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Student::getName))), ArrayList::new));
不知道为啥 string 类型字段就报错空指针,int 没错。
就是为了要去重重复对象,重复对象的判断条件是某个字段的值相同。找了好多都是这么写的,但是一跑就报错。很神奇。
