标签:java学习 string indexof 字符串 count
public class StringCount {
public static void main(String[] args) {
String ss = "kkabkkcdkkefkkskk";
String key = "kk";
System.out.println(getSubCount_2(ss,key));
}
public static int getSubCount_2(String str,String key) {
int count = 0 ;
int index = 0 ;
while ((index = str.indexOf(key)) != -1) {
System.out.println(str);
str = str.substring(index+key.length());
count++;
}
return count ;
}
}本文出自 “azhome” 博客,请务必保留此出处http://azhome.blog.51cto.com/9306775/1546368
标签:java学习 string indexof 字符串 count
原文地址:http://azhome.blog.51cto.com/9306775/1546368