public class StrCount { public static void main(String[] args) { int a = Count("aabbdbaaee3f","a"); System.out.println(a); } public static int Count(String str1,String str2) { int index = 0; int count = 0; while((index = str.indexOf(str2, index)) != -1) { count++; index = index + str2.length(); } return count; } }
计算某字符串在另一个字符串中出现的次数
猜你喜欢
转载自www.cnblogs.com/c-l-w/p/9760725.html
今日推荐
周排行