//按专业和年级去重,专业和年纪一样时表示重复对象
List<Class> distinctClass = classList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getProfessionId() + ";" + o.getGrade()))), ArrayList::new));
标签:Collectors,list,字段,集合,new,java8 From: https://www.cnblogs.com/wj123bk/p/16992587.html