public static void main(String[] args) {
String s = "中国中国中中中国中国国国国国国国国国";
char cs[] = s.toCharArray();
Map<Character,Integer> map = new HashMap();
char maxchar = 0;
int maxcount = 0;
for(char c:cs)
{
if(map.get(c)==null)
{
map.put(c, 1);
}else
{
map.put(c, map.get(c)+1);
}
if(map.get(c)>maxcount)
{
maxchar = c;
maxcount = map.get(c);
}
}
System.out.println("频率最高字符:"+maxchar+" 出现次数:"+maxcount);
}