我試圖將2維字符串數組複製到另一個2維字符串數組。然後將第二個2維字符串數組轉換爲字符串。之後,打印出字符串 ,但字符串不顯示什麼是假設... 我試圖做到這一點,而不使用Java庫。Java將2維字符串數組轉換爲字符串
public class Train {
//public static void main (String args){
public static void main(String[] args) {
String [][] ff = { {"0","1","2","3","4","5","6","7"},
{"0","1","2","3","4","5","6","7"},
{"0","1","2","3","4","5","6","7"},
{"0","1","2","3","4","5","6","7"},
{"0","1","2","3","4","5","6","7"},
{"0","1","2","3","4","5","6","7"},
{"0","1","2","3","4","5","6","7"},
{"0","1","2","3","4","5","6","7"} };
String[][] IP = new String[8][8];
int x=0, y=0;
for(int i = 1; i < 8; i +=2){
for(int j = 7; j>=0 ; j--){
y= 0;
IP[x][y]=ff[j][i];
System.out.print(IP[x][y]);
y++;
}
if (i==7){
i=-2;
x++;
}
}
String zz= "";
for(int p = 0; p<8;p++){
for(int q= 0 ; q< 8; q++){
zz += IP[p][q];
System.out.print(zz);
}
}
}
}
謝謝
什麼是你的問題?你喲有錯誤嗎? – 2014-02-18 07:41:14
您正在將元素從ff [] []始終複製到IP [0] [0](x,y永遠不會更改)。 – wxyz
我得到這個[[Ljava.lang.String; @ 134510ac – user3322264