统计大串中小串出现的次数

package com.toov5.test;

public class Test3 {
  
    public static void main(String[] args) {
        String max = "okokvv,okwer,wroksdf,fsdf";
        String min = "ok";
        
        int count  = 0;
        int index  = 0;
        while ((index = max.indexOf(min)) !=-1 ) {
            count ++;
            max = max.substring(index+min.length());
        }
        System.out.println(count);
    }
    
    
}

 

posted @ 2018-12-05 20:25  toov5  阅读(278)  评论(0编辑  收藏  举报