有谁愿意帮帮我吗,感谢大侠
[code="java"]
/**
* @param args
*/
public static void main(String[] args) throws Exception
{
String contents = "Hello World";
char[] content = contents.toCharArray();
Map map = new HashMap();
for(int i = 0; i < content.length; i ++)
if(-1 != contents.indexOf(content[i]))
if(null != map.get(content[i]))
map.put(content[i], map.get(content[i]) + 1);
else
map.put(content[i], 1);
int maxValue = map.get(content[0]);
char str = ' ';
for(int j = 0; j < content.length; j ++)
if(maxValue < map.get(content[j]))
{
maxValue = map.get(content[j]);
str = content[j];
}
System.out.println("现次数最多的字符:" + str + " 出现次数:" + maxValue);
}
[/code]