findfirst

1. Predicate가 적어도 한 요소와 일치하는지 확인 - anyMatch if(menu.stream().anyMatch(Dish::isVegetarian)) { System.out.prinln("The menu is (somewhat) vegetarian friendly!!"); } anyMatch는 불리언을 반환하므로 최종 연산이다. 2. Predicate가 모든 요소와 일치하는지 검사 - allMatch, noneMatch allMatch메서드는 anyMatch와 달리 모든 요소가 Predicate와 일치하는지 검사한다. boolean isHealthy = menu.stream().allMatch(d -> d.getCalories() < 1000); noneMatch는 allMatch와 반대 연..
깡냉쓰
'findfirst' 태그의 글 목록