java8 stream统计字符串中每个字母的个数
String str="qqqweaaaasdffg";
HashMap<String, Long> collect = Stream.of(str.split("")).collect(Collectors.groupingBy(Function.identity(), HashMap::new, Collectors.counting()));
collect.entrySet().forEach(e->{
System.out.println(e.getKey()+"============"+e.getValue());
});

浙公网安备 33010602011771号