IntStream empty()是java.util.stream.IntStream中的方法。此方法返回空的順序IntStream。
用法:
static <T> Stream<T> empty() Where, T is the type of stream elements, and the function returns an empty sequential stream.
示例1:創建空的IntStream。
// Java code for IntStream empty()
import java.util.*;
import java.util.stream.IntStream;
class GFG {
// Driver code
public static void main(String[] args) {
// creating an empty IntStream, a sequence of
// primitive int-valued elements
IntStream stream = IntStream.empty();
// Displaying an empty sequential stream
System.out.println(stream.count());
}
}
輸出:
0
示例2:創建空的LongStream。
// Java code for LongStream empty() method
import java.util.*;
import java.util.stream.LongStream;
class GFG {
// Driver code
public static void main(String[] args) {
// creating an empty LongStream, a sequence of
// primitive long-valued elements
LongStream stream = LongStream.empty();
// Displaying an empty sequential stream
System.out.println(stream.count());
}
}
輸出:
0
相關用法
- Java IntStream max()用法及代碼示例
- Java IntStream min()用法及代碼示例
- Java IntStream distinct()用法及代碼示例
- Java IntStream peek()用法及代碼示例
- Java IntStream anyMatch()用法及代碼示例
- Java IntStream allMatch()用法及代碼示例
- Java IntStream average()用法及代碼示例
- Java IntStream filter()用法及代碼示例
- Java IntStream toArray()用法及代碼示例
- Java IntStream count()用法及代碼示例
- Java IntStream noneMatch()用法及代碼示例
- Java IntStream.Builder build()用法及代碼示例
- Java IntStream codePoints()用法及代碼示例
- Java IntStream reduce(IntBinaryOperator op)用法及代碼示例
- Java IntStream reduce(int identity, IntBinaryOperator op)用法及代碼示例
注:本文由純淨天空篩選整理自Sahil_Bansall大神的英文原創作品 IntStream empty() in Java with examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。