Java求字符串中出现次数最多的字符,如String Str = "aaabbcddddee";那么输出:d 4 ;若String Str = "aaabbcddddeexxxxxx";那么输出:x 6
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Iterator;
public class Maxkey
{
public static void main(String[] args)
{
String str ="aabbbbcc";
char[] StrArr = str.toCharArray();
Map<Character,Integer> map = MapFunction(StrArr);
char ch = FindMapMaxValue(map);
}
public static Map<Character,Integer> MapFunction(char[] StrArr)
{
Map<Character,Integer> map = new HashMap<Character,Integer>();
if(!(StrArr == null || StrArr.length == 0))
{