/**
     * 判断字符串中某个字符存在的个数
     * @param str1  完整字符串
     * @param str2  要统计匹配个数的字符
     * @return
     */
    public static int countStr(String str1, String str2) {
        int count=0;
        if (str1.indexOf(str2) == -1) {
            return 0;
        }
        while(str1.indexOf(str2)!=-1){
            count++;
            str1=str1.substring(str1.indexOf(str2)+str2.length());
        }
        return count;
    }

 

相关文章:

  • 2021-09-23
  • 2021-07-25
  • 2021-07-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案