[HD Pg 370, Sec. 12.5.3 - using-predicate-interface]
Posted: Wed Jul 17, 2024 9:11 am
hello,
i don't understand anything about predicated, i feel like this chapter miss parts.
and why this code is incorrect? in java like everything accept the subtype, here why it doesnt accept subclass type?
i don't understand anything about predicated, i feel like this chapter miss parts.
Code: Select all
public static boolean checkList(List list, Predicate<List> p){
return p.test(list);
}
public static void main(String[] args) {
boolean b = checkList(new ArrayList<>(), (ArrayList al) -> al.isEmpty());
System.out.println(b);
}