Arrays.stream(int[]) in Java

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

Syntax:

IntStream java.util.Arrays.stream(int[] array)

This method takes one argument of type int array as its parameter. This method returns a sequential IntStream 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: an IntStream for the array.

Exceptions: NA

Approach

Java

import java.util.Arrays;

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

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

Output:

4


No comments:

Post a Comment