java string fill_Java 2d String數組填充數組

String[][] work = new String[3][];

thats work

work[0] = new String[3];

work[0][0]=" !!! ";

work[0][1]=" !!! ";

work[0][2]=" !!! ";

work[1] = new String[3];

work[1][0]=" !!! ";

work[1][1]=" !!! ";

work[1][2]=" !!! ";

work[2] = new String[3];

work[2][0]=" !!! ";

work[2][1]=" !!! ";

work[2][2]=" !!! ";

thats dont work for me i dont know where is mistake Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 3

那不適合我,我不知道哪里是錯誤線程中的異常“AWT-EventQueue-0”java.lang.ArrayIndexOutOfBoundsException:3

for(int i=0;i<13;i++){

work[i]= new String[3];

}

for(int i=0;i<13;i++){

for(int j=0;j<3;j++){

work[i][j]=" !!! ";

}

}

for(String[] x: work){

for(String e : x){

System.out.println(e);

}System.out.println();

}

mistake is here String[][] work = new String[13][]; 3->13

錯誤在這里String [] [] work = new String [13] []; 3-> 13

1 个解决方案

#1

You should change

你應該改變

for(int i=0;i<13;i++) {

to

for(int i=0;i

This will save you from similar typos.

這樣可以避免類似的拼寫錯誤。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值