List<? extends A> list2 = list1;
This means a list of a specific subtype A.
If you can use List<A>what "list A of all its subclasses" means, you will lose compile-time security. Imagine:
List<B> list1 = ..;
List<A> list2 = list1;
list2.add(new C());
for (B b : list1) {
}
source
share