- public static int countStr(String str1, String str2) {
- int counter=0;
- if (str1.indexOf(str2) == -1) {
- return 0;
- }
- while(str1.indexOf(str2)!=-1){
- counter++;
- str1=str1.substring(str1.indexOf(str2)+str2.length());
- }
- return counter;
- }
Java中判断字符串中相同字符的个数
最新推荐文章于 2022-11-17 01:21:16 发布