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