过年啦

切割字符串,将字符串数组转换为流后 以计算出所有整数的乘积

private int calculateProduct(String str) {
        return Arrays.stream(str.split(","))
                .filter(this::checkIsEmpty)
                .mapToInt(Integer::parseInt)
                .reduce(1, (a, b) -> a * b);
    }
posted @ 2024-11-25 10:46  一只快乐的柠檬精J  阅读(8)  评论(0)    收藏  举报