#java steam 小技巧:#Map<Long, Long> result = relations.stream() .collect(Collectors.groupingBy(a -> a.getRuleId(), Collectors.counting()));