I am currently working on making my code contain more generics. I encountered a compilation error which looks quite complicated but which I was able to reduce to an equivalent error in the following code:
List<List<?>> a = new ArrayList<List<Integer>>();
Why this happens? What can I do to fix it?
Instances of a generic class with different type parameters are not related, i.e. even though
Stringis a subtype ofObject,List<String>is not a subtype ofList<Object>, and even thoughList<Integer>is a subtype ofList<?>,List<List<Integer>>is not a subtype ofList<List<?>>.Perhaps you are looking for