标题: 这两个做记录好 [打印本页] 作者: changfa 时间: 2016-9-9 12:15 标题: 这两个做记录好 String s ="ABCDEabcd123456!@#$%^";
String max = "woaiheima,heimabutongyubaima,wulunheimahaishibaima,zhaodaogongzuojiushihaoma";
//定义小串
String min = "heima";
int count = 0;
int index = 0;
/*while(max.indexOf(min, index)!=-1){
count++;
index =max.indexOf(min,index)+min.length();
}*/
while((index = max.indexOf(min))!=-1){
count++;
max = max.substring(index+min.length());
}