ITeye博客

Stream - Match

fairy_xzc · 2018-06-19 21:52 · FP · 编程语言 · Markdown

原创转载请注明出处:http://agilestyle.iteye.com/blog/2425204

 

allMatch

private static void allMatch() {
    Stream<Integer> stream = Arrays.stream(new Integer[]{1, 2, 3, 4, 5, 6, 7});

    boolean result = stream.allMatch(i -> i > 0);

    System.out.println(result);
}

 

anyMatch

private static void anyMatch() {
    Stream<Integer> stream = Arrays.stream(new Integer[]{1, 2, 3, 4, 5, 6, 7});

    boolean result = stream.anyMatch(i -> i > 6);

    System.out.println(result);
}

 

noneMatch

private static void noneMatch() {
    Stream<Integer> stream = Arrays.stream(new Integer[]{1, 2, 3, 4, 5, 6, 7});

    boolean result = stream.noneMatch(i -> i < 0);

    System.out.println(result);
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。