public class StrTimes {
public static void main(String[] args) {
String s = "qq";
String src = new Scanner(System.in).next();//键盘输入src
strTime(s,src);
}
public static void strTime(String s,String src){
//将src中出现的s字符串替换为空,然后计算
int count = (src.length()-src.replace("qq","").length())/s.length();
System.out.println(count);
}
}
编写一个方法统计出字符串s在字符串src中出现的次数
最新推荐文章于 2023-07-11 15:51:29 发布