Hi guys,
Somebody could I tell me, Why in the marked line, cause a compile error "cannot find symbol" if l tends to be a List and it has the add
method?.
import java.util.*;
class Shape{
}
class Rect extends Shape{
}
class Circle extends Shape{
}
class ShadedRect extends Rect{
}
class Generics2{
public static void add(List<? extends Shape> l,int pos, Rect r){
l.add(pos, r); // Compile Error in this line.Why?
}
public static void main(String args[]){
List<ShadedRect> l = new LinkedList<ShadedRect>();
add( l,0, new ShadedRect() );
}
}