int a[][]= {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
int rowLength=a.length;
int colLength=a[0].length;
System.out.println("rowsize:"+a.length);
System.out.println("colsize:"+a[0].length);
for(int row=0;row<rowLength;row++) {
for(int col=0;col<colLength;col++) {
System.out.print(a[row][col]+",");
}
System.out.println();
}
int b[][]=new int[colLength][rowLength];
for(int i=0;i<rowLength;i++) {
for(int j=0;j<colLength;j++) {
b[j][i]=a[i][j];
}
}
for(int i=0;i<colLength;i++) {
for(int j=0;j<rowLength;j++) {
System.out.print(b[i][j]+",");
}
System.out.println();
}
rowsize:3
colsize:4
1,2,3,4,
5,6,7,8,
9,10,11,12,
1,5,9,
2,6,10,
3,7,11,
4,8,12,