在一个长字符串中判断存在几个另一个短字符串
2015-08-18 20:01
477 查看
public int getTimes(String str1, String str2) { int count = 0; int start; while ((start = (str1.indexOf(str2))) >= 0) { count++; str1 = str1.substring(start + str2.length()); } return count; }str1是长字符串,str2是短字符串。上面方法返回值即为长字符串中有几个短字符串。
相关文章推荐
- git 远程同步命令
- cocos2d-x开发日志10 ——贪食蛇源码
- 迷宫寻宝(一)(bfs)
- 多校第八场 hdu 5389
- hdu 5400 Arithmetic Sequence(模拟)
- PHP-FPM介绍
- 【JZOJ】3187 的士
- 全排列
- 获取当前 IE 地址栏中的 URL
- Delphi实现HTMLWebBrowser实现HTML界面
- NOIP2012 借教室
- 2015-8-18总结
- UVA 10100- Longest Match(dp之最长公共子序列)
- OpenCV之LBP
- 安卓 一
- hdoj 1905 Pseudoprime numbers
- UVALive 6129 Sofa, So Good
- LinearLayout
- C++程序设计 - Week 3 类和对象进阶
- 五大布局——线性布局