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("");
}
}
转载于:https://blog.51cto.com/7883830/1619665