Arrays.stream(double[]) in Java

Arrays.stream(double[]): This method is available in java.util.Arrays class of Java.

Syntax:

DoubleStream java.util.Arrays.stream(double[] array)

This method takes one argument of type double array as its parameter. This method returns a sequential DoubleStream with the specified array as its source.

Parameters: One parameter is required for this method,

array: the array, assumed to be unmodified during use.

Returns: a DoubleStream for the array.

Exceptions: NA

Approach

Java

import java.util.Arrays;

public class Arraysstreamdouble {
    public static void main(String[] args) {

        double array[] = { 1, 2, 10, 5 };
        System.out.println(Arrays.stream(array).count());
    }
}

Output:

4


No comments:

Post a Comment