一、Stream
java8 List去重
- 去除List中重复的String
List uniqueStr = list.stream().distinct().collect(Collectors.toList());
- 按对象属性去重
users = users.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(UserInDeptDto::getUserId))), ArrayList::new)
);