紧急求助!!兄弟快过来看看

my1982 2007-03-28 05:55:17
用java 写一个方法,里面有两个参数,一个是子字符串,另一个是父字符串

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


这个是明天的笔试题目,兄弟们有谁知道就帮你定一个吧.全部的分都给你们了
...全文
183 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yanglei031 2007-03-28
  • 打赏
  • 举报
回复
同意1楼的,有开源包 干嘛还自己写
long_drago 2007-03-28
  • 打赏
  • 举报
回复
int count= 0;
while(true){
int temp = fs.indexOf(ss)
if(-1 != temp){
count++;
fs = fs.subString(temp + ss.length());
}else{
break;
}
}
long_drago 2007-03-28
  • 打赏
  • 举报
回复
int x= 0;
while(true){

}
For_suzhen 2007-03-28
  • 打赏
  • 举报
回复
写错了
应该是
int x = 0;
int count = 0;
while(x <strfather.length())
{
x=strfather.indexOf(strson);
count ++;
if(x + strson.length()>strfather.length()){
break;
}
strfather = strfather.substring(x);
x=0;
}
For_suzhen 2007-03-28
  • 打赏
  • 举报
回复
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;
}
}
MyDream83 2007-03-28
  • 打赏
  • 举报
回复
笔试题都能搞到。。
craig_wolfdon 2007-03-28
  • 打赏
  • 举报
回复
学习了,
syhan 2007-03-28
  • 打赏
  • 举报
回复
org.apache.commons里的扩展类都是好东西,学习了
liaohaiying 2007-03-28
  • 打赏
  • 举报
回复
试试楼上的吧
zuguanqun 2007-03-28
  • 打赏
  • 举报
回复
org.apache.commons.lang.StringUtils

manuscript = StringUtils.lowerCase(manuscript);

// count the occurrences of "futility"

int numFutility = StringUtils.countMatches( manuscript, " futility " );
manuscript 父字符串 futility子字符串

81,116

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧