IntStream anyMatch(IntPredicate predicate) example
Description
IntStream anyMatch(IntPredicate predicate)
returns whether any elements of this stream match the provided predicate.
Syntax
anyMatch
has the following syntax.
boolean anyMatch(IntPredicate predicate)
Example
The following example shows how to use anyMatch
.
import java.util.stream.IntStream;
/* w ww .j a va 2s . co m*/
public class Main {
public static void main(String[] args) {
IntStream i = IntStream.of(6,5,7,1, 2, 3, 3);
boolean d = i.anyMatch(n-> n > 0 );
System.out.println(d);
}
}
The code above generates the following result.