The following code is available:
int[] arr1 = {10, 20, 30, 40}; System.out.println(Arrays.deepToString(arr1)); Here the compiler produces an error:
incompatible types: int [] cannot be converted to java.lang.Object []
The following code is compiled without errors:
int[][] arr2 = {{10, 20}, {30, 40}}; System.out.println(Arrays.deepToString(arr1)); Why int[] cannot be converted to Object ? Are arrays of primitives not objects? And why is the two-dimensional array of primitives int[][] in Object perfectly converted?
Object[], and not at all inObject. And in this case it cannot, because primitives are not successors Object. - etkiint[][]- is no longer primitive and is inherited fromObject? - darkoint[]also not primitive. The JVM looks at what type is contained in the array and whether it is possible to bring to it the type of the contents of the current array. - etki