标签: java arrays bluej
Hey guys, i have this while loop for variable 'i' and i have created a board[][] which is 2x2 (so sizeX for the board is 2 in this example). The problem is i can't work out why it isn't leaving the while loop if it goes through one of the 'if' statements starting with 'i=1' and then it then sets 'i=i+1' (=2) but doesn't leave the while statement and tries to see what board[2][x] is equal to when obviously that is out of the bounds of the board. Sorry for confusing explanation i hope you understand...
答案 0 :(得分:-1)
我假设您是编程新手,因为您使用的是BlueJ。 当你的第二个循环运行时,我猜你的行x = x使x保持在范围内,因此循环永远不会退出。
帮助的一件好事是使用调试器或打印语句来显示每个阶段x和i的值。这会很快让你知道出了什么问题。