java-统计大字符串中小字符串的个数

package com.day7.one;

  public class Test4 {

  /**
  * 需求:统计大串中小串出现的次数
  */
    public static void main(String[] args) {
      String max="woaikobe,kobebutongxuqitaqiuxing,zhejiushiwoaikobedeyuanyin";
      String min="kobe";
      int count=0;
      int index=0;
      while((index=max.indexOf(min))!=-1)
      {
        count++;
        max=max.substring(index+min.length());
      }
      System.out.println(count);
    }

}

原文地址:https://www.cnblogs.com/zhujialei123/p/8120287.html