如何获取一个字符串在另个字符串中出现的所有位置 如果一个字符串在另一个字符串中出现了多次,怎么能获得它出现的所有位置?怎么实现效率会比较好? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class StringTest { public static void main(String args[]) { String s = "hello, this is a test this is a test this is a this is test"; String p = "test"; for(int i = 0; i < s.length(); i ++) { int at = s.indexOf(p, i); if(at < 0) { break; } System.out.println(p + "@" + at); i = at; } }} JFreeChart传值乱码的问题 finally的神秘问题 【求助】新手请教关于编写一个wordcounter小程序的问题 初学者的简单问题,关于数学函数!! 变量的定义问题! Java 小小算法问题 谁能给我JBUILDER8的序列号啊,谢谢!!!!!!!!!! 外企招聘,欢迎刚毕业的大学生应聘! JPopupMenu的使用 代码中的细节问题 下面这个语句创建几个对象啊?为什么 请教html Parser的两个应用
public class StringTest { public static void main(String args[]) {
String s = "hello, this is a test this is a test this is a this is test";
String p = "test";
for(int i = 0; i < s.length(); i ++) {
int at = s.indexOf(p, i);
if(at < 0) {
break;
}
System.out.println(p + "@" + at);
i = at;
}
}
}