I want to create a simple generic method to count the numbers after applying the filter based on the provided predicate.
static int count(Collection < ? extends Number > numbers, Predicate < ? extends Number > predicate) {
return numbers.stream().filter(predicate).count();
}
It gives me the following error:
incompatible types: Predicate cannot be converted to
Predicate<? super CAP#2>where CAP#1, CAP#2 are fresh type-variables:CAP#1 extends Number from capture of ? extends Number
CAP#2 extends Number from capture of ? extends Number