日期:2014-05-18  浏览次数:20801 次

紧急求助!!兄弟快过来看看
用java   写一个方法,里面有两个参数,一个是子字符串,另一个是父字符串  

算子字符串在父字符串出现的次数


这个是明天的笔试题目,兄弟们有谁知道就帮你定一个吧.全部的分都给你们了

------解决方案--------------------
org.apache.commons.lang.StringUtils

manuscript = StringUtils.lowerCase(manuscript);

// count the occurrences of "futility "

int numFutility = StringUtils.countMatches( manuscript, " futility " );
manuscript 父字符串 futility子字符串
------解决方案--------------------
试试楼上的吧
------解决方案--------------------
org.apache.commons里的扩展类都是好东西,学习了
------解决方案--------------------
学习了,
------解决方案--------------------
笔试题都能搞到。。

------解决方案--------------------
int x = 0;
int count = 0;
while(x <strfather.length())
{
x=strfather.indexOf(strson);
strfather = strfather.substring(x);
count ++;
if(x + strson.length()> strfather.length()){
break;
}
}
------解决方案--------------------
int x= 0;
while(true){

}
------解决方案--------------------
同意1楼的,有开源包 干嘛还自己写