问题
How come
int[] arr = new int[5];
Object[] obj = arr;
produces a compilation error while
int[][] arr = new int[5][5];
Object[] obj = arr;
doesn't?
回答1:
int[]
is an Object
, so array of int[]
is an array of Object
.
来源:https://stackoverflow.com/questions/62435112/does-a-primitive-type-multi-dimensional-array-gets-casted-to-object-type-in-java