Java from list <B> to list <a>, where B extends A
Is it possible? if not, why is this not possible in Java?
interface B extends A {} public List<B> getList(); List<A> = getList(); // Type mismatch: cannot convert from List<B> to List<A> I think that the topic I'm looking for is โcovariant typesโ like here and here , but its muddy and it doesn't solve my problem.
+4
3 answers