In order to troubleshoot the Object array created in C code with JNI, I have created the pure Java code with an array of Object arrays as follows. I would like to access this array in the manner like two dimensional Object array (Object[][]) using [][] operator. However the code crashes when casting the array to Object[][] with the following exception.
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [[Ljava.lang.Object
Object[] outerArray = new Object[3];
outerArray[0] = new Object[] {1,2,3,4,5};
outerArray[1] = new Object[] {10,20,30,40,50};
outerArray[2] = new Object[] {100,200,300,400,500};
Object o = ((Object[])outerArray[0])[0]; // (1) OK but awkward
Object[][] = (Object[][])outerArray; // (2) Runtime error!!
o = outerArray[0][0]; // (3) I want to do this
Can anyone help me?
Object[][]in the first place?