It is made in java, that generics are not automatically converted from Generic<A>
to Generic<SupeclassOfA>
.
For example, if write a method
public static void printList(List<Object> list) {
for (Object elem : list)
System.out.println(elem + " ");
System.out.println();
}
it will not accept List<Integer>
. I need to rewrite header for List<?>
and it will start work although the code will be the same.
So, why is it done?
Suppose I redesign Java
so that List<?>
always mean the same as List<Object>
. What problems will I face?