// 根据name去重
List<Person> unique = persons.stream().collect(
            Collectors.collectingAndThen(
                    Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Person::getName))), ArrayList::new)
);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2022-01-19
  • 2021-12-11
  • 2021-10-16
  • 2022-12-23
  • 2021-12-17
猜你喜欢
  • 2022-12-23
  • 2021-10-11
  • 2021-10-25
  • 2021-12-03
相关资源
相似解决方案