There is a class for every array type, so there’s a class for int[]
, there’s a class for Foo[]
. These classes are created by JVM. You can access them by int[].class
, Foo[].class
. The direct super class of these classes are Object.class
public static void main(String[] args)
{
test(int[].class);
test(String[].class);
}
static void test(Class clazz)
{
System.out.println(clazz.getName());
System.out.println(clazz.getSuperclass());
for(Class face : clazz.getInterfaces())
System.out.println(face);
}
There’s also a compile-time subtyping rule, if A
is subtype of B
, A[]
is subtype of B[]
.