小编sle*_*043的帖子

加入多个IntStream

我试图得到某些整数,我将通过流来获取所有整数,但是,它们基本上被添加到我将在稍后使用的新整数流中.

为了填充新的整数流,我创建了多个IntStream,然后使用IntStream构建器将它们附加到新的IntStream,如下所示:

有没有更好的方法来解决这个问题:

    IntStream rightSide = IntStream.range(8, this.rows.getSlotAmount()).map(value -> value + 9);
    IntStream leftSide = IntStream.range(0, this.rows.getSlotAmount()).map(value -> value % 9);
    IntStream top = IntStream.range(0, 9);
    IntStream bottom = IntStream.range(this.rows.getSlotAmount() - 9, this.rows.getSlotAmount());

    IntStream.Builder slots = IntStream.builder();

    rightSide.forEach(slots::add);
    leftSide.forEach(slots::add);
    top.forEach(slots::add);
    bottom.forEach(slots::add);

    slots.build().forEach(this::methodReference);
Run Code Online (Sandbox Code Playgroud)

java java-stream

3
推荐指数
1
解决办法
776
查看次数

标签 统计

java ×1

java-stream ×1