- public class Test3_String {
- /**
- * @param args
- */
- public static void main(String[] args) {
- //大串
- String max = "abcacdacbacd";
- //小串
- String mix = "a";
- //定义计数器
- int count = 0;
- //定义索引
- int index = 0;
- while ((index = max.indexOf(mix))!=-1) {
- count++;
- max = max.substring(index + mix.length());
-
- }
- System.out.println(count);
- }
- }
复制代码
|
|