sequential()
DoubleStream类的方法返回顺序的等效流。
语法如下
DoubleStream sequential()
要在Java中使用DoubleStream类,请导入以下包
import java.util.stream.DoubleStream;
创建一个DoubleStream并添加一些元素
DoubleStream doubleStream1 = DoubleStream.of(45.8, 67.9, 78.5, 90.6, 97.4);
现在创建一个等效的顺序流
DoubleStream doubleStream2 = doubleStream1.sequential();
以下是sequential()
在Java中实现DoubleStream方法的示例
import java.util.*; import java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { DoubleStream doubleStream1 = DoubleStream.of(45.8, 67.9, 78.5, 90.6, 97.4); DoubleStream doubleStream2 = doubleStream1.sequential(); System.out.println("Equivalent new stream..."); doubleStream2.forEach(System.out::println); } }
输出结果
Equivalent new stream... 45.8 67.9 78.5 90.6 97.4