首页上一页 1 下一页尾页 2 条记录 1/1页
如题,看视频真的不能活学活用
String s = "abkjshfabdkglgnadabalfmaba";
String flag = "ab";
List<Integer> strIndex = new LinkedList<Integer>();
int index = 0;
while (index < s.length()) {
index = s.indexOf(flag, index);
if (index == -1) {
break;
}
strIndex.add(index);
index++;
}
Integer nums[] = strIndex.toArray(new Integer[strIndex.size()]);
for (int num : nums) {
System.out.println(num);
}