In this method,
public static void printClass(Class<?> cl) {
cl.getTypeParameters();
}
the return type of cl.getTypeParameters()
is TypeVariable<Class<capture of ?>>[]
, but why this result can assign to a variable with type TypeVariable<? extends Class<?>>[]
, that is
public static void printClass(Class<?> cl) {
TypeVariable<? extends Class<?>>[] typeVariables = cl.getTypeParameters();
}
What I have known is that if
B[] b = new B[]{...};
A[] a = b;
then A
must be some supertype of B
. In other words, why TypeVariable<? extends Class<?>>
is a supertype of TypeVariable<Class<capture of ?>>
?
1