public class TestString {
public static void main(String[] args) {
String s1 = "abcdefghiabcjklmnopqrabcstuvwxyzabc";
String s2 = "a";
int count = (s1.length() - s1.replace(s2, "").length())/s2.length();
System.out.println(count);
}
}
记算出一个字符串出现的次数
最新推荐文章于 2023-02-09 23:56:47 发布