posted 15 years ago
Following is the piece of code from K&B 1.5 pg 587
Besideds above code theres a parent class Animal and Dog class extends Animal.
Now compiling above code gives error
The explanation given for error states that ArrayList of subtype cannot be assigned to ArrayList of supertype, rightly so. But I feel that even if the
checkAll method was modified as below
It would still give compilation error just because we cannot pass ArrayList reference to a List reference regardless of the generic type used. Please correct me if i am wrong.