package com.heima.test;
import java.io.ObjectOutputStream.PutField;
import java.util.HashMap;
public class Test8 {
/**统计字符串中每个字符出现的个数
* @param args
*/
public static void main(String[] args) {
String s = "asdasdksdfksdjfsdwerw";
HashMap<Character, Integer> hm = new HashMap<Character, Integer>();
char [] arr = s.toCharArray();
for (char key : arr) {
if(!hm.containsKey(key)){
hm.put(key, 1);
}else{
hm.put(key, hm.get(key) + 1);
}
}
for (Character key : hm.keySet()) {
System.out.println(key + "有"+hm.get(key)+"次!");
}
}
}