Java Streams - IntStream anyMatch(IntPredicate predicate) example








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;

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.