The DoubleStream
interface’s toArray()
method creates an array of the double
type. This array consists of the stream’s elements. This method is a terminal/last operation in the stream pipeline.
double[] toArray();
The method has no parameters.
The method returns an array of the double
type.
import java.util.Arrays;import java.util.stream.DoubleStream;class Main {public static void main(String[] args) {DoubleStream doubleStream = DoubleStream.of(5.6, 10.9, 12.4, 34.2, 0.00032);double[] doubleArray = doubleStream.toArray();System.out.println("Converting the DoubleStream to an array - " + Arrays.toString(doubleArray));}}
Arrays
class and the DoubleStream
interface.double
values.double
type array using the toArray()
method.