美文网首页
字符串出现的次数

字符串出现的次数

作者: 一起走天下 | 来源:发表于2019-02-19 09:33 被阅读0次

    public static int getCount(String str,String sq){
    int idx = 0;
    int count = 0;
    while ((idx = str.indexOf(sq,idx))!=-1){
    count++;
    idx += sq.length();
    }
    return count;
    }

    相关文章

      网友评论

          本文标题:字符串出现的次数

          本文链接:https://www.haomeiwen.com/subject/pixxyqtx.html