还有比下面这个计算给定字符串的字符数更简单的方法
String word = "AAABBB";
Map<String, Integer> charCount = new HashMap();
for(String charr: word.split("")){
Integer added = charCount.putIfAbsent(charr, 1);
if(added != null)
charCount.computeIfPresent(charr,(k,v) -> v+1);
}
System.out.println(charCount);