DoubleStream of(double t)
DoubleStream of(double t)返回包含單個元素的順序DoubleStream。
用法:
static DoubleStream of(double t)
參數:
- DoubleStream : 一係列原始雙值元素。
- t : 表示DoubleStream中的單個元素。
返回值:DoubleStream of(double t)返回包含單個指定元素的順序DoubleStream。
例:
// Java code for DoubleStream of(double t)
// to get a sequential DoubleStream
// containing a single element.
import java.util.*;
import java.util.stream.DoubleStream;
class GFG {
// Driver code
public static void main(String[] args)
{
// Creating a DoubleStream having single
// element only
DoubleStream stream = DoubleStream.of(8.2);
// Displaying the DoubleStream having
// single element
stream.forEach(System.out::println);
}
}
輸出:
8.2
DoubleStream of(雙精度…值)
DoubleStream of(雙精度…值)返回其元素為指定值的順序有序流。
用法:
static DoubleStream of(double... values)
參數:
- DoubleStream : 一係列原始雙值元素。
- values : 表示新流的元素。
返回值:DoubleStream of(double…values)返回一個順序有序的流,其元素為指定值。
示例1:
// Java code for DoubleStream of(double... values)
// to get a sequential ordered stream whose
// elements are the specified values.
import java.util.*;
import java.util.stream.DoubleStream;
class GFG {
// Driver code
public static void main(String[] args)
{
// Creating an DoubleStream
DoubleStream stream = DoubleStream.of(8.2, 5.6, 4.1);
// Displaying the sequential ordered stream
stream.forEach(System.out::println);
}
}
輸出:
8.2 5.6 4.1
示例2:
// Java code for DoubleStream of(double... values)
// to get a sequential ordered stream whose
// elements are the specified values.
import java.util.*;
import java.util.stream.DoubleStream;
class GFG {
// Driver code
public static void main(String[] args)
{
// Creating an DoubleStream
DoubleStream stream = DoubleStream.of(5.2, 4.2, 6.3);
// Storing the count of elements in DoubleStream
long total = stream.count();
// Displaying the count of elements
System.out.println(total);
}
}
輸出:
3
相關用法
- Java DoubleStream sum()用法及代碼示例
- Java DoubleStream iterator()用法及代碼示例
- Java DoubleStream mapToObj()用法及代碼示例
- Java DoubleStream skip()用法及代碼示例
- Java DoubleStream sorted()用法及代碼示例
- Java DoubleStream summaryStatistics()用法及代碼示例
- Java DoubleStream mapToInt()用法及代碼示例
- Java DoubleStream concat()用法及代碼示例
- Java DoubleStream min()用法及代碼示例
- Java DoubleStream parallel()用法及代碼示例
- Java DoubleStream sequential()用法及代碼示例
- Java DoubleStream max()用法及代碼示例
- Java DoubleStream toArray()用法及代碼示例
- Java DoubleStream mapToLong()用法及代碼示例
- Java DoubleStream count()用法及代碼示例
注:本文由純淨天空篩選整理自Sahil_Bansall大神的英文原創作品 DoubleStream of() in Java。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。