Stream noneMatch(Predicate predicate) example
Description
Stream noneMatch(Predicate<? super T> predicate)
tells whether
no elements of this stream match the provided predicate.
Syntax
noneMatch
has the following syntax.
boolean noneMatch(Predicate<? super T> predicate)
Example
The following example shows how to use noneMatch
.
import java.util.Arrays;
import java.util.List;
/*from w ww . ja v a 2 s .c o m*/
public class Main {
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5);
boolean o = numbers.stream()
.noneMatch(n-> n % 2 ==0);
System.out.println(o);
}
}
The code above generates the following result.