还有比下面这个计算给定字符串的字符数更简单的方法
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);
String word = "AAA BBB CCC AAA BBB";
Map<String, Long> map = Arrays.stream(word.split(" ")).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
System.out.println(map);