我有以下代码:
List<? super Integer> numbers = new ArrayList<Number>();
numbers.add(new Integer(10));
Number object = numbers.get(0); //this doesn't compile??
Object object = numbers.get(0); //this does compile
然后,如果我这样做:
numbers.add(new Object()); //doesn't compile in contradiction to above statement
这是什么原因?