Class.isAssignableFrom()
essentially checks the subtyping relation. "subtype" and "subclass" are two different concepts. The class hierarchy (i.e. subclassing) is only a part of subtyping.
Primitive types and array types have special cases for subtyping.
The rules for subtyping of array types are like this (note that ">1" means "is a directy subtype of"):
- If
S
and T
are both reference types, then S[]
>1 T[]
iff S
>1 T
.
Object
>1 Object[]
Cloneable
>1 Object[]
java.io.Serializable
>1 Object[]
- If
p
is a primitive type, then:
Object
>1 p[]
Cloneable
>1 p[]
java.io.Serializable
>1 p[]
The important part for your question is the very first item: an array type X[]
is a subtype of an array type Y[]
if and only if the component type X
is a subtype of the component type Y
.
Also note that strictly speaking neither Object[]
nor String[]
are classes. They are "only" types. While every class implicitly is a type, the reverse is not true. Another example of types that are not classes are the primitive types: boolean
, byte
, char
, short
, int
, long
, float
and double
are types, but they are not classes.
Another cause for confusion is the fact that you can easily get java.lang.Class
objects representing those types. Again: This does not mean that those types are classes.