Java中的LongStream.Builder build()方法
build()
LongStream.Builder类的方法将构建流,并将此构建器转换为已构建状态。
语法如下
LongStream build()
要在Java中使用LongStream.Builder类,请导入以下包
import java.util.stream.LongStream;
以下是build()
在Java中实现LongStream.Builder方法的示例
示例
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream.Builder builder = LongStream.builder(); builder.accept(255L); builder.accept(570L); builder.accept(355L); builder.accept(155L); builder.accept(955L); builder.accept(1800L); builder.accept(155L); builder.accept(2900L); builder.build().forEach(System.out::println); } }
输出结果
255 570 355 155 955 1800 155 2900