读书人

!兄弟快过来看看

发布时间: 2011-12-25 23:21:20 作者: rapoo

紧急求助!!兄弟快过来看看
用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楼的,有开源包 干嘛还自己写

读书人网 >Java Web开发

热点推荐