java.lang.ArrayIndexOutOfBoundsException
当我尝试运行某些字母(e)并且我不知道如何解决它时,我的代码中的线程“main”中出现错误异常:26。
该数组包含 26 个字符(字母表中的每个字母)。任何人都可以在代码中看到问题吗?
//Breaking up the letters from the input and placing them in an array
char[] plaintext = input.toCharArray();
//For loops that will match length of input against alphabet and move the letter 14 spaces
for(int i = 0;i<plaintext.length;i++) {
for(int j = 0 ; j<25;j++) {
if(j<=12 && plaintext[i]==alphabet[j]) {
plaintext[i] = alphabet[j+14];
break;
}
//Else if the input letter is near the end of the alphabet then reset back to the start of the alphabet
else if(plaintext[i] == alphabet[j]) {
plaintext[i] = alphabet [j-26];
}
}
}