源字符串例如:123java123jajajavavava123java
要删除的字符串:java
最终结果123123123 count=5.
请问这是怎么实现的啊???
8条回答 默认 最新
- qq_33133645 2017-10-30 17:35关注
String s1 = "123java123jajajavavava123java";
String s2 = "java";
String result = s1;
while(result.contains(s2)){
result = result.replace(s2,"");
System.out.println(result);} int count = (s1.length() - result.length()) / s2.length(); System.out.println(count);
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报