List<?> l1 = new ArrayList<>();
List<? extends Object> l2 = l1;
no compile error here, however
List<?> l1 = new ArrayList<>();
List<? super Object> l2 = l1;
there is a compile error. It's so confused!
List<?> l1 = new ArrayList<>();
List<? extends Object> l2 = l1;
no compile error here, however
List<?> l1 = new ArrayList<>();
List<? super Object> l2 = l1;
there is a compile error. It's so confused!
Try putting any type into the diamond.
List<?> l1 = new ArrayList<String>();
Now:
List<? extends Object> l2 = l1;
Yup, String
extends Object
.
List<? super Object> l2 = l1;
Nope, String
is not a supertype of Object
.