首页 > 编程语言 > 详细

Java中判断字符串中相同字符的个数

时间:2015-10-16 11:52:03      阅读:316      评论:0      收藏:0      [点我收藏+]
  1. public static int countStr(String str1, String str2) {   
  2.         int counter=0;  
  3.         if (str1.indexOf(str2) == -1) {    
  4.             return 0;  
  5.         }   
  6.             while(str1.indexOf(str2)!=-1){  
  7.                 counter++;  
  8.                 str1=str1.substring(str1.indexOf(str2)+str2.length());  
  9.             }  
  10.             return counter;    
  11.     }   

Java中判断字符串中相同字符的个数

原文:http://www.cnblogs.com/yanduanduan/p/4884697.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!