Error
The method filter(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("Str").forEach(System.out::println);
Cause
The method filter expects the argument as the Predicate and not the String.
Resolution
Specify the Predicate as the filter 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).forEach(System.out::println);
The method filter(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("Str").forEach(System.out::println);
Cause
The method filter expects the argument as the Predicate and not the String.
Resolution
Specify the Predicate as the filter 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).forEach(System.out::println);