且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

indexOf查找字符串中单词的所有出现

更新时间:2022-11-07 22:51:15

您可以跟踪索引:

int index = theString.indexOf("the");
while(index >= 0) {
    index = theString.indexOf("the", index+1);
    counter2++;
}