class Point{
}
class SubPoint extends Point {
}
public class
Test {
public static void main(
String[] args) {
List<? extends Point> listExtends = new ArrayList<SubPoint>();
listExtends.add(new Point()); //not compile #1
listExtends.add(new SubPoint());//not compile #2
List<? super SubPoint> listSuper = new ArrayList<Point>();
listSuper.add(new Point());//not compile #3
listSuper.add(new SubPoint());// #4
}
}
PS:JDK 1.6
why the #1,2,3 does not compile and the #4 can be compiled.
thanks .