Java中的LongStream Sequence()方法
sequential()
Java中LongStream类的方法返回顺序的等效流。
语法如下-
LongStream sequential()
要在Java中使用LongStream类,请导入以下包-
import java.util.stream.LongStream;
创建一个LongStream并添加一些元素-
LongStream longStream = LongStream.of(50L, 70L, 100L, 150L, 200L, 300L);
现在,返回顺序的等效流-
LongStream res = longStream.sequential();
以下是sequential()
在Java中实现LongStream方法的示例-
示例
import java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.of(50L, 70L, 100L, 150L, 200L, 300L); LongStream res = longStream.sequential(); res.forEach(System.out::println); } }
输出结果
50 70 100 150 200 300