JAVA List按照指定字段去重重复
List<TalentPlanStudentEntity> studentList = relatePlanStudentList.stream() .collect(Collectors.collectingAndThen(Collectors.toCollection( () -> new TreeSet<>(Comparator.comparing(TalentPlanStudentEntity::getUserId))), ArrayList::new)); List<TalentPlanStudentEntity> studentList = new ArrayList<>(relatePlanStudentList.stream() .collect(Collectors.toMap(TalentPlanStudentEntity::getUserId, Function.identity(), (oldValue, newValue) -> oldValue)) .values());
标签:JAVA,stream,Collectors,List,LIST,字段,new From: https://www.cnblogs.com/lewisat/p/18186872