I have no idea why it's not working.
Error message in eclipse: The method test(Fruit, capture#1-of ? extends Fruit) in the type BiPredicate is not applicable for the arguments (Fruit, Mango)
import java.util.function.BiPredicate;
public class PredTest {
public static void main(String[] args) {
class Fruit {
public String name;
public String color;
Fruit(String name) {this.name = name; }
};
class Apple extends Fruit {
Apple() {super("Apple");}
};
class Mango extends Fruit {
Mango() {super("Mango");}
};
BiPredicate<Fruit, ? extends Fruit> tester = (f, nf) -> {
System.out.println(nf.name);
return true;
};
Fruit f = new Fruit("Not named");
Apple a = new Apple();
Mango m = new Mango();
// ########### I see error in the below line
System.out.println(tester.test(f, m));
}
}