![]() |
VOOZH | about |
The anyMatch() method of the Stream interface checks whether any element of the stream matches the given condition (predicate). It is a short-circuiting terminal operation, meaning it stops processing as soon as a matching element is found.
Example:
true
Explanation: stream().anyMatch(n -> n > 2) checks if any element in the list is greater than 2.
boolean anyMatch(Predicate<? super T> predicate)
Example 1: This example checks whether any number in the list satisfies the given mathematical condition.
true
Explanation:
Example 2: This example checks whether any string has an uppercase character at index 1.
true
Explanation:
Note: It returns false for empty streams.