While using method Arrays.deepToString(Object [] a) I am facing this problem which I can put down in this way.
Object [] not_allowed = new int[]{7, 9, 8};
Object [] allowed = new int[][]{{1, 2, 3}, {6, 5, 4}};
Why i am not allowed to assign int[] to Object[] in single dimension case but i am allowed to do such in multidimension case.
Primitive types like
intare not Objects while an array is an Object– you can assign any array to an Object referencenew int[][]is an array of objects and thus can be assigned toObject[]. You may want to write a utility method like this to do what you want:Example:
Output: