IntStream sequential()返回顺序的IntStream。它可能会返回自身,这是因为流已经是顺序的,或者是因为基础流状态已被修改为顺序的。 IntStream sequential()是中间操作。在Stream实例上调用中间操作,并在完成处理后将中间实例作为输出提供。
用法:
IntStream sequential() Where, IntStream is a sequence of primitive int-valued element.
示例1:
// Java code for IntStream sequential()
// to return a sequential IntStream.
import java.util.*;
import java.util.stream.IntStream;
class GFG {
// Driver code
public static void main(String[] args)
{
// Creating an IntStream
IntStream stream = IntStream.of(3, 5, 9, 12, 14);
// Using IntStream sequential()
IntStream streamNew = stream.sequential();
// Displaying sequential IntStream
streamNew.forEach(System.out::println);
}
}
输出:
3 5 9 12 14
示例2:
// Java code for IntStream sequential()
// to return a sequential IntStream.
import java.util.*;
import java.util.stream.IntStream;
class GFG {
// Driver code
public static void main(String[] args)
{
// Creating an IntStream of elements
// in range [-2, 4)
IntStream stream = IntStream.range(-2, 4);
// Using IntStream sequential()
IntStream streamNew = stream.sequential();
// Displaying sequential IntStream
streamNew.forEach(System.out::println);
}
}
输出:
-2 -1 0 1 2 3
相关用法
- Java LongStream sequential()用法及代码示例
- Java DoubleStream sequential()用法及代码示例
- Java IntStream sum()用法及代码示例
- Java IntStream of()用法及代码示例
- Java IntStream parallel()用法及代码示例
- Java IntStream mapToLong()用法及代码示例
- Java IntStream asDoubleStream()用法及代码示例
- Java IntStream mapToDouble()用法及代码示例
- Java IntStream builder()用法及代码示例
- Java IntStream rangeClosed()用法及代码示例
- Java IntStream limit()用法及代码示例
- Java IntStream iterator()用法及代码示例
- Java IntStream sorted()用法及代码示例
- Java IntStream range()用法及代码示例
注:本文由纯净天空筛选整理自Sahil_Bansall大神的英文原创作品 IntStream sequential() in Java。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。