Java nested generic type

Fundamentally, List<List<?>> and List<? extends List<?>> have distinct type arguments. It’s actually the case that one is a subtype of the other, but first let’s learn more about what they mean individually. Understanding semantic differences Generally speaking, the wildcard ? represents some “missing information”. It means “there was a type argument here once, but we don’t know … Read more

Difference between an unbound wildcard and a raw type

How List<?> differs from List<Object> The main difference is that the first line compiles but the second does not: List<?> list = new ArrayList<String> (); List<Object> list = new ArrayList<String> (); However, because you don’t know what the generic type of List<?> is, you can’t use its parameterized methods: List<?> list = new ArrayList<String> (); … Read more