Wildcards and Subtyping
class A { /* ... */ }
class B extends A { /* ... */ }B b = new B();
A a = b;List<B> lb = new ArrayList<>();
List<A> la = lb; // compile-time error

Last updated
class A { /* ... */ }
class B extends A { /* ... */ }B b = new B();
A a = b;List<B> lb = new ArrayList<>();
List<A> la = lb; // compile-time error

Last updated
List<? extends Integer> intList = new ArrayList<>();
List<? extends Number> numList = intList; // OK. List<? extends Integer> is a subtype of List<? extends Number>