int[][] A = {{11, 7},{-20,-22}};
int[][] B = {{A[0].length},{A.length}};
for(int i = 0; i < A.length;i ++){
for(int j = 0; j < A[0].length;j ++){
System.out.print(A[i][j] + "\t");
}
System.out.println();
}
for(int i = 0; i < A.length;i ++){
for(int j = 0; j < A[0].length;j ++){
B[i][j] = A[j][i];
}
}
The error is this:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1 at j.pkg1.J1.ex31(J1.java:132) C:\*******************************\NetBeans\Cache.2\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds)
Line 132 is B[i][j] = A[j][i];