If I have a method in MyClass
such as
setSuperClassList(List<Superclass>)
...should I be able to do this:
new MyClass().setSuperClassList(new ArrayList<Subclass>())
It appears this won't compile. Why?
Try setSuperClassList(List<? extends Superclass>)
.
Also check PECS to see wether you should use ? extends
or ? super
.