代码: char[] chars = str.toCharArray(); HashMap<Character,Integer> map = new HashMap(); for (int i = 0; i < chars.length; i++) { if(map.containsKey(chars[i])){ int count = map.get(chars[i]); map.put(chars[i],++count); }else { map.put(chars[i],1); } } //这一步很绝,是我没想到但是差点想到的 for (int i = 0; i &l...