최종연산 2
● allmatch, anymatch, nonmatch package org.example; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { boolean result = IntStream.of(1, 2, 3, 4, 5) .allMatch(value -> value % 2 == 0); System.out.println(result); System.out.println(); result = IntStream.of(1, 2, 3, 4, 5) .anyMatch(value -> value % 2 == 0); System.out.println(result); System.out.println..
2024. 2. 16.
스트림의 최종연산
package org.example; import java.util.stream.IntStream; public class Main10 { public static void main(String[] args) { int sum = IntStream.of(1,3,5,7,9) .sum(); System.out.println("sum = "+sum); long count = IntStream.of(1,3,5,7,9) .count(); System.out.println("count = "+count); IntStream.of(1,3,5,7,9) .average() .ifPresent(value -> System.out.println("average = "+value)); IntStream.of(1,3,5,7,9..
2024. 2. 15.