当前位置:网站首页>Lambda end operation find and match allmatch

Lambda end operation find and match allmatch

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

allMatch

​ It can be used to judge whether they all meet the matching conditions , The result is boolean type . If they all agree, the result is true, Otherwise, the result is false.

Example :

​ Judge whether all writers are adults

//         Judge whether all writers are adults 
        List<Author> authors = getAuthors();
        boolean flag = authors.stream()
                .allMatch(author -> author.getAge() >= 18);
        System.out.println(flag);

原网站

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