build()
LongStream.Builder类的方法生成流并返回生成的流。以下是语法:
LongStream build()
为Java中的LongStream.Builder类导入以下软件包:
import java.util.stream.LongStream;
声明一个LongStream.Builder并添加元素:
LongStream.Builder builder = LongStream.builder(); builder.add(24000L); builder.add(47470L); builder.add(12999L);
现在,使用该build()
方法来构建流:
builder.build()
以下是显示如何build()
在Java中实现LongStream.Builder方法的示例:
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream.Builder builder = LongStream.builder(); builder.add(24000L); builder.add(47470L); builder.add(12999L); builder.add(55757L); builder.add(12999L); builder.add(55757L); builder.build().forEach(System.out::println); } }
24000 47470 12999 55757 12999 55757