반응형
allMatch()
-
[Java] 스트림(Stream)의 최종 연산 - 요소의 검사 : anyMatch(), allMatch(), noneMatch()Java/Stream(스트림) 2022. 7. 25. 15:50
목차 스트림(Stream)의 최종 연산 - 요소의 검사 : anyMatch(), allMatch(), noneMatch()1. anyMatch()해당 스트림의 일부 요소가 특정 조건을 만족할 경우 true, 만족하지 않을 경우 false를 반환합니다. 예제) 해당 스트림에서 일부 요소가 문자열 'A'로 시작하는지 확인public static void createStreamAnyMacth() { List strings = Arrays.asList("A1", "A2", "B1", "B2"); boolean isMatch = strings.stream().anyMatch(s -> s.startsWith("A")); System.out.println("anyMatch : " + isMatch);}Conso..