📜  Java中的 DoubleStream empty() 示例

📅  最后修改于: 2022-05-13 01:54:25.694000             🧑  作者: Mango

Java中的 DoubleStream empty() 示例

DoubleStream empty()是Java.util.stream.DoubleStream 中的一个方法。此方法返回一个空的顺序 DoubleStream。
句法 :

static DoubleStream empty()

Where, DoubleStream is a sequence of primitive double-valued
elements and the function returns an empty sequential stream.

示例 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()));
    }
}
输出:
[]