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

Error

The method allMatch(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");
strSet.stream().filter(capStartFilter).allMatch("Test");

Cause

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

Resolution

Specify the Predicate as the allMatch 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).allMatch(capStartFilter);