统计大串中小串出现的次数
来源:互联网 发布:箪食壶浆以迎将军乎 编辑:程序博客网 时间:2024/06/05 10:45
统计大串中小串出现的次数
public class Test3 { public static void main(String[] args) { String str="woaijavawozhenaijavawozhendeaijavawozhendehenaijavaxinbuxinwoaijavagun"; String searchStr="java"; System.out.println(getCount1(str, searchStr));} //从指定的字符串中查找小串出现的次数 方法1 public static int getCount1(String str,String searchStr){ int count=0; int searchStrlen=searchStr.length(); while(str.indexOf(searchStr)!=-1){ count++; str=str.substring(str.indexOf(searchStr)+searchStrlen); } return count; } //从指定的字符串中查找小串出现的次数 方法2 public static int getCount2(String str,String searchStr){ int count=0; int searchStrlen=searchStr.length(); for(int i=0;i<str.length();i++){ char temp=str.charAt(i); if(temp=='j'){ String strTemp=str.substring(i, i+searchStrlen); if("java".equals(strTemp)) count++; } } return count; }}
0 0
- 统计大串中小串出现的次数
- 统计大串中小串出现的次数 *举例:在字符串”woaijavawozhenaijavawozhendeaijavawozhendehenai
- java面试题10--String--统计大串中小串出现的次数
- 字符串中连续子串出现次数统计,获取连续出现次数最多的子串
- 统计字符串中子串出现的次数与位置
- 统计子串在另一个字符中出现的次数
- 字符串操作:统计子串在主串中出现的次数
- POJ 3461 Oulipo(KMP:统计一个串出现的次数)
- C语言 字符串 统计字串子母串出现的次数
- kmp统计子串出现次数
- 统计子串出现次数 STL map
- 统计出现字符的次数
- 统计字符串出现的次数
- 字符串的出现次数统计
- 统计字符串出现的次数
- 电话号码出现的次数统计
- 统计字符串出现的次数
- 统计空格出现的次数
- 常见计算机概念或术语
- POJ 1003 Hangover
- Pull解析器解析XML文件
- mysql体系结构
- 文章标题
- 统计大串中小串出现的次数
- C++ lambda 表达式
- 学习strcpy函数中的问题
- 非常好的理解遗传算法的例子
- 17个学术论文搜索引擎
- [poj3735 Training little cat]【矩阵快速幂】
- 【C语言】猴子吃桃问题
- 第六周项目六 复数模板类(3)
- HTTP请求的基本过程