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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。