Could someone please explain to me why the following doesn�t work:
List<? extends Number> list = new ArrayList<Integer>();
list.add( new Integer(1) );
This doesn�t compile:
cannot find symbol
symbol : method add(java.lang.Integer)
location: interface java.util.List<capture of ? extends java.lang.Number>
list.add( new Integer(1) );
The compiler doesn�t complain when I instantiate the List, only when I try to add something to it. Why does this happen?
Thanks for the help.
Cheers
Matthijs