Java ArrayIndexOutOfBounds Exception
Vielleicht habe ich das schon zu lange angeschaut, da ich das Problem nicht finden kann, aber es sollte etwas Einfaches sein. Ich erhalte eine ArrayIndexOutOfBounds-Ausnahme in der Zeile:
nextWord = MyArray[i + 1].toLowerCase();
ann jemand sehen, waru
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);
}
}
Vielen Dank