Error
The method filter(Predicate<? super Integer>) in the type Stream<Integer> is not applicable for the arguments (Predicate<String>)
while using Predicate and Lambda Expressions in Java 8.
Error Type
Compile Time ( Java 8 )
Sample Code
List<Integer> intList = new ArrayList<Integer>();
intList.add(1);
intList.add(2);
intList.add(3);
Predicate<String> prd = p->p.charAt(0) > 64 && p.charAt(0) < 91;
System.out.println(intList.stream().parallel().filter(prd).collect(Collectors.groupingBy(p->(Integer)p%2)));
Cause
Predicate Input has been declared as String but the Filter expects the Predicate of ? super Integer.
Resolution
Either use the Predicate with Collection of Strings or Change the Predicate to operate on Integers.
The method filter(Predicate<? super Integer>) in the type Stream<Integer> is not applicable for the arguments (Predicate<String>)
while using Predicate and Lambda Expressions in Java 8.
Error Type
Compile Time ( Java 8 )
Sample Code
List<Integer> intList = new ArrayList<Integer>();
intList.add(1);
intList.add(2);
intList.add(3);
Predicate<String> prd = p->p.charAt(0) > 64 && p.charAt(0) < 91;
System.out.println(intList.stream().parallel().filter(prd).collect(Collectors.groupingBy(p->(Integer)p%2)));
Cause
Predicate Input has been declared as String but the Filter expects the Predicate of ? super Integer.
Resolution
Either use the Predicate with Collection of Strings or Change the Predicate to operate on Integers.