Map<Object, Long> a1Map = groupStoreVisiList.stream().filter(map->map.getA1() != null)//这里需要加个判断,该字段不能为null
.collect(Collectors.groupingBy(p -> p.getA1(),Collectors.counting()));
element cannot be mapped to a null key
原文:https://www.cnblogs.com/magichu/p/14884331.html