我正在編寫一個基本代碼,用於檢查tweet是否包含標籤或提及,如果其中任何一個有空格或標籤,則不會計數。我也收到了'未密封的字符'信息,我不知道爲什麼。錯誤 - StringIndexOutOfBoundsException:字符串索引超出範圍:4
for (int i=0; i < tweet.length(); i++) {
char currentchar = tweet.charAt(i);
char nextcar = tweet.charAt(i+1);
if (currentchar == '#') {
if (! (nextcar == ' ') && ! (nextcar == '/t')) {
numofhashtags++;
}
}
if (currentchar == '@') {
if ((nextcar != ' ') && (nextcar != '/t')) {
numofmentions++;
}
}
}
'我
Tom
你明白錯誤信息是什麼意思嗎? –