import java.util.HashMap;
import java.util.Map;
public class Lianxi {
/**
* 统计字符串中每个字符出现的次数
String str = "aaaabbbcccccccccc";
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "aaaabbbcccccccccc";
char[] arr = str.toCharArray();
//创建映射对象
Map<Character, Integer> map = new HashMap<>();
for (char c : arr) {
map.put(c, map.containsKey(c) ? map.get(c)+1:1);
}
for (Character key : map.keySet()) {
System.out.println(key+" : "+map.get(key));
}
}
}