对象过滤 List<Person> uniqueByName = persons.stream().collect( Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Person::getName))), ArrayList::new) );
java8 Stram 日常使用
最新推荐文章于 2024-07-19 17:37:28 发布
对象过滤 List<Person> uniqueByName = persons.stream().collect( Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Person::getName))), ArrayList::new) );