posted 16 years ago
Please help me explaining why this snippet would give ,capture-of error.
when i call this method.
This is exapmly frm K&B ,chap7pg 590.
With super-bounded ,we can pass generic type or super type but still erorr is coming.
void checkAnimals(List<? super Animal> animals) //Animal +subtype +no modification promise
{
animals.add(new Dog());
for(Animal a :animals ) //------animals give error
{
if(a!=null)
a.checkUp();
}
}