public class Test {
public static void main(String[] args) {
String[][] oldArray = { {"公開單位1","公開單位2","公開單位3","公開單位4","公開單位5","公開單位6"},
{"DL_GKBM1","DL_GKBM2","DL_GKBM3","DL_GKBM4","DL_GKBM5","DL_GKBM6"},
{"string1","string2","string3","string4","string5","string6"},
{"text1","text2","text3","text4","text5","text6"},
{"like1","like2","like3","like4","like5","like6"}};
String[][] newArray = new String[oldArray[0].length][oldArray.length];
for(int i=0 ; i<oldArray.length;i++){
for(int j=0; j<oldArray[i].length;j++){
newArray[j][i]=oldArray[i][j]; //轉置核心
}
}
System.out.println("This is old Array");
for(int i = 0;i<newArray.length;i++){
for(int j = 0;j<newArray[i].length;j++){
System.out.print(newArray[i][j]+" ");
}
System.out.println("");
}
}ide