ERROR - The method anyMatch(Predicate) in the type Stream is not applicable for the arguments (String)

Error

The method anyMatch(Predicate<? super String>) in the type Stream<String> is not applicable for the arguments (String)

Error Type

Compile Time ( Java 8 )

Sample Code

Set<String> strSet = new HashSet<String>();
strSet.add("Value");
strSet.add("value");
strSet.add("ValuE");
strSet.add("valuE");
System.out.println(strSet.stream().anyMatch("Value"));

Cause

The method anyMatch expects the argument as the Predicate and not the String. 

Resolution

Specify the Predicate as the anyMatch function argument.

Set<String> strSet = new HashSet<String>();
strSet.add("Value");
strSet.add("value");
strSet.add("ValuE");
strSet.add("valuE");
   
Predicate<String> capStartFilter = (p) -> (p.charAt(0) < 90);
    
strSet.stream().filter(capStartFilter).anyMatch(capStartFilter);