The rules for subtyping arrays are as follows, from the Java Language Specification, where >
means is a supertype
If S and T are both reference types, then
S[]
>T[]
iffS
>T
....
- If P is a primitive type, then:
Object >1 P[]
Cloneable >1 P[]
java.io.Serializable >1 P[]
where >1
means is a direct supertype.
In this case S
is Object
and T
is Integer
, So because Integer
is a subtype of Object
and therefore Integer[]
is a subtype of Object[]
, you can use it as an argument to a method that expects an Object[]
.
However, for int
, which is a primitive, Object
is the supertype of int[]
and therefore int[]
cannot be used where an Object[]
is expected.
The notion of wrapper classes doesn't apply here.