JAVA LIST按照指定字段去重重复

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());

 

 

        TreeMap<String, List<SdsTest>> treeMap = list.stream().collect(Collectors.groupingBy(SdsTest::getKey, TreeMap::new, Collectors.toList()));

 

posted on 2024-05-11 17:25  lewisat  阅读(91)  评论(0编辑  收藏  举报

导航