也许我一直在寻找这个太久,因为我无法找到问题,但它应该是简单的东西。我收到一条线上的ArrayIndexOutOfBounds异常:的Java异常的ArrayIndexOutOfBounds
nextWord = MyArray[i + 1].toLowerCase();
任何人都可以看到为什么?
String currentWord = "";
String nextWord = "";
for (int i = 0; i <= MyArray.length; i++) {
// If not at the end of the array
if (MyArray.length > 0 && i < MyArray.length) {
currentWord = MyArray[i].toLowerCase();
nextWord = MyArray[i + 1].toLowerCase(); /* EXCEPTION */
System.out.println("CURRENT WORD: " + currentWord);
System.out.println("NEXT WORD: " + nextWord);
}
}
谢谢!
谢谢澄清! – littleK 2010-10-28 16:09:02