The anyMatch() method returns elements whether any match with the provided predicate. The anyMatch() method executes untill determining the result. Its terminate the loop execution when found any match and returns the value.
boolean anyMatch(Predicate super T> predicate)
//Importing required classes import java.util.ArrayList; import java.util.List; import java.util.stream.*; public class AnyMatchMethodExample { public static void main(String args[]){ //Declaring List List<
Integer
> intList = new ArrayList<
Integer
>(); intList.add( 6 ); intList.add( 11 ); intList.add( 14 ); intList.add( 7 ); intList.add( 3 ); intList.add( 2 ); intList.add( 16 ); intList.add( 15 ); intList.add( 19 ); //calling anymatch method boolean result = intList.stream().anyMatch( n -> n==14 ); System.out.println( result ) } } Output: true