Stream - Match
原创转载请注明出处: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);
}