怎么在一串长字符串中找出出现最多次数的字符?
package ind.idehub.day1;import java.util.HashMap;
import java.util.Map;
public class CountMax {
public static void main(String[] args) {
// TODO Auto-generated method stub
String s = "hidjahgugahjjaiosdhgbh";
Map <Character, Integer> map = new <Character, Integer> HashMap();
int len = s.length();
for(int i=0; i<s.length();i++) {
Character k = s.charAt(i);
map.put(k, (map.get(k) == null ? 1: map.get(k) + 1));
}
System.out.println(map);
}
}
输出结果 : {a=3, b=1, s=1, d=2, u=1, g=3, h=5, i=2, j=3, o=1}
怎么提取出出现最多次数的字符?