When I try to assign an object of a type to a List<List<Object>>variable with a wildcard parameter List<List<?>>, I get the error "incompatible types: List<List<Object>>cannot be converted to List<List<?>>".
Example:
List<List<Object>> x = new ArrayList<>();
List<List<?>> y = x;
On the other hand, assigning an object of a type to a type List<Object>variable List<?>works fine.
Example:
List<Object> x = new ArrayList<>();
List<?> y = x;
Why? Why does this work for List<?>, but not for List<List<?>>?
Wednesday: JDK 7, Netbeans 8
source
share