創建對象
Student student1 = new Student("張三",20,"周");
Student student2 = new Student("李四",30,"上號");
Student student3 = new Student("王五",18,"阿西吧");
Student student4 = new Student("氨綸",19,"阿西吧");
Student student5 = new Student("氨綸",19,"阿西吧1");
其中對於name去重
List<Student> collect = Arrays.asList(student1,student2,student3,student4,student5);
List<Student> unique = collect.stream().collect(Collectors.collectingAndThen(
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Student::getName))), ArrayList::new));
unique.forEach(p -> System.out.println(p));