public class StatisticZEN { public static void main(String[] args) { String str = "中国aadf的111萨bbb菲的zz萨菲"; showFrequency(str); private static HashMap<Character, Integer> showFrequency(String str) { HashMap<Character, Integer> map = new HashMap<Character, Integer>(); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); Integer num = map.get(c); if(num == null) num = 1; else num ++; map.put(c,num); } return map; } }
原文:http://www.cnblogs.com/lxcmyf/p/7106993.html