Why am i not allowed to do this?
public abstract class A {} public class B extends A {} ... public ArrayList<A> foo() { return new ArrayList<B>(); } I changed to public since there are so many people that love to point stupid errors.
Why should i have to write ALL this code. Just to satisfy Java's non-senses?
public List<A> foo() { List<A> aList = new ArrayList<A>(); List<B> bList = new ArrayList<B>(); /* fill bList*/ for (B b : bList) { aList.add(b); } return aList; }