ツイートにハッシュタグまたは言葉が含まれているかどうかを確認する基本コードを作成しています。次のスペースまたはタブがある場合はカウントされません。私はまた、 '閉じられていない文字のリテラル'メッセージを取得していると私はなぜか分からない。Error- 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
エラーメッセージの意味を理解していますか? –