当前位置:网站首页>Lambda termination operation find and match anymatch

Lambda termination operation find and match anymatch

2022-06-13 03:48:00 Leon_ Jinhai_ Sun

anyMatch

​ It can be used to judge whether there are any matching elements , The result is boolean type .

Example :

​ Judge whether there is an age in 29 The above Writers

//         Judge whether there is an age in 29 The above Writers 
        List<Author> authors = getAuthors();
        boolean flag = authors.stream()
                .anyMatch(author -> author.getAge() > 29);
        System.out.println(flag);

原网站

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