importJava.util.Collections;
importjava.util.Map;
importjava.util.TreeMap;
publicclassTestStringSplict {
publicstaticvoidmain(String[] args){
String str ="aaaaaaaccccccccccccccccccccccaaaabb";
// 用map实现
// TreeMapmap = new TreeMap();
// for(Character ch : str.toCharArray()){
// if((ch>='a' && ch'A' && ch
// Integer count = map.get(ch);
// map.put(ch, null==count?1:count+1);
// }
// }
//
// System.out.println(Collections.max(map.values()));
//用普通数组实现
int[] aa =newint[60];
for(chartemp:str.toCharArray()){
if((temp>=65&& temp<=90)||(temp>=97&& temp<=122)){
temp -=65;
aa[temp]++;
}
}
intmax = aa[0];intposition =0;
for(inti=0;i
if(aa[i]>max){
max = aa[i]; position = i;
}
}
System.out.println(max);
System.out.println("字母"+(char)(position+65) +"出现"+ max +"次");
}
}