當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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


相關用法


注:本文由純淨天空篩選整理自Sahil_Bansall大神的英文原創作品 DoubleStream empty() in Java with examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。