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;
}
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
网友评论