0
該代碼編譯並適用於任何傳遞的字符串,但它不適用於檢查元音。它拋出一個字符串越界錯誤,我不知道爲什麼。輔音的檢查工作。獲取字符串越界異常
下面是代碼:
public String catchword(String word){
int x = 0;
for(x=0; x<word.length()+1; x++){
boolean v = Vowel(word.charAt(x));
boolean c = Consonant(word.charAt(x));
if (x<word.length()-1){
v = Vowel(word.charAt(x+1));
} else{
v = true;
}
if (c == true && v == true){
word = word.substring(0,x+1) + "op" + word.substring(x+1,word.length());
x = x+3;
}
}
System.out.print(word);
return word;
}
'for(x = 0; x
Tunaki
啊。我現在看到了這個問題。謝謝 – john