我正在尝试解决arrayoutofbounds异常
确切的错误是:
线程“主”中的异常
java.lang.ArrayIndexOutOfBoundsException:
-1
Java结果:1
public static void emptyBox() {
int , boxRow, boxColumn, i, j;
emptyBox = 0;
Row = 0;
Column = 0;
for (i = 0; (i < grid.length) && !(1 == emptyBox); i++) {
for (j = 0; (i < grid[i].length) && !(1 == emptyBox); j++) {
if (grid[i][j] == 0) {
emptyBox = 0;
Row = 0;
Column = 0;
}
}
}
}
I've tried a few attempts at debugging but no dice.
最佳答案
for (i = 0; (i < grid.length) && !(1 == emptyBoxFound); i++) {
for (j = 0; (i < grid[i].length) && !(1 == emptyBoxFound); j++) {
---------------------^
应该是
j
而不是i
我不知道那是不是唯一的问题,但是...
关于java - 解决arrayoutbounds,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5267355/