Java DoubleStream empty()方法及实例
DoubleStream empty() 是java.util.stream.DoubleStream中的一个方法。该方法返回一个空的连续的DoubleStream。
语法
static DoubleStream empty()
其中,DoubleStream是一个原始双值元素的序列
元素的序列,该函数返回一个空的顺序流。
例1 :
// Java code for DoubleStream empty()
import java.util.*;
import java.util.stream.DoubleStream;
class GFG {
// Driver code
public static void main(String[] args)
{
// creating an empty DoubleStream, a sequence of
// primitive double-valued elements
DoubleStream stream = DoubleStream.empty();
// Displaying an empty sequential stream
System.out.println(stream.count());
}
}
输出:
0
例2 :
// Java code for DoubleStream empty()
import java.util.*;
import java.util.stream.DoubleStream;
class GFG {
// Driver code
public static void main(String[] args)
{
// creating an empty DoubleStream, a sequence of
// primitive double-valued elements
DoubleStream stream = DoubleStream.empty();
// Displaying an empty sequential stream
System.out.println(Arrays.toString(stream.toArray()));
}
}
输出:
[]