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());
}
System.out.println(count); |
|