过年啦

切割字段串后,对切割后的每一个类型进行 统计数量 操作

    private Map<Integer, Long> calculateCount(String str) {
        return Arrays.stream(str.split(","))
                .filter(this::checkIsEmpty)
                .mapToInt(Integer::parseInt).boxed()
                .collect(Collectors.groupingBy(
                        num -> num,
                        Collectors.counting()
                ));
    }
posted @ 2024-11-25 10:41  一只快乐的柠檬精J  阅读(5)  评论(0)    收藏  举报