在一个字符串中查找子串的个数

u778198358 94 0 TXT 2019-05-13 21:05:27

在一个字符串s中查找有几个字串subs,结果返回字串的个数。主要用的indexOf()函数。

用户评论
请输入评论内容
评分:
Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

很不错的资源,值得推荐

Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

不错的代码!

Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

不错,学习了,借鉴着做了一个新的程序。

Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

代码有误,如果是两个以上匹配还只返回一个。 private static int find(StringBuffer sb2, String qs) { int number =0; if(sb2.indexOf(qs)== -1){ return 0 ; }else{ while(sb2.length() > qs.length()){ if(sb2.indexOf(qs)!=0){ number++; } sb2.delete(0, sb2.indexOf(qs)+qs.length()); } } retu

Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

不错,可以借鉴。。。

Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

不错的资料啊 哈哈

Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

不错,学习了,借鉴着做了一个新的程序。

Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

很好,可以借鉴!

Generic placeholder image 卡了网匿名网友 2019-05-13 21:05:27

不错,简单明了