public static int getCount(String str,int chr){//利用2个字符串间的关系得出重复的数
int count=0;
int index=0;
//
while((index=str.indexOf(chr,index))!=-1){
index=index+1;//针对单个字符串的
count++;//计数器
}
return count;
public class StringTest {
public static void main(String[] args) {
String s="abcdefabced";
char[] ch=s.toCharArray();
TreeMap<Character,Integer> hm = new TreeMap<Character,Integer>();