package stream;

import java.util.stream.Stream;

public class StreamExample03 {
    public static void main(String[] args) {
        // 需要满足所有元素都匹配条件
        boolean allMatch = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9)
                .allMatch(i -> i > 4);
        System.out.println(allMatch);// false

        // 只要有一个元素满足匹配条件
        boolean anyMatch = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9)
                .anyMatch(x -> x > 4);
        System.out.println(anyMatch);// true

        // 所有元素都不满足条件
        boolean noneMatch = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9)
                .noneMatch(x -> x > 4);
        System.out.println(noneMatch);// false
    }
}