//为啥非要用集合啊
public class Times {
public static void main(String[] args) {
String s1="asdfasdfassadafasdfas";
String s2="as";
int index=0;
while(s1.contains(s2)){
s1=s1.substring(s1.indexOf(s2)+ s2.length());
index++;
}
System.out.println("出现的次数为:"+index);
}
}
|
|