当前位置:网站首页>Lambda intermediate operation skip

Lambda intermediate operation skip

2022-06-12 00:43:00 Leon_ Jinhai_ Sun

skip

​ Skip previous in stream n Elements , Return the remaining elements

for example :

​ Print writers other than the oldest , No duplicate elements are required , And in descending order of age .

//         Print writers other than the oldest , No duplicate elements are required , And in descending order of age .
        List<Author> authors = getAuthors();
        authors.stream()
                .distinct()
                .sorted()
                .skip(1)
                .forEach(author -> System.out.println(author.getName()));

原网站

版权声明
本文为[Leon_ Jinhai_ Sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206120036470323.html