Convert int array to IntStream

Description

The following code shows how to convert int array to IntStream.

Example


import java.util.Arrays;
import java.util.stream.IntStream;
/*w  w w .j a v  a  2 s  .c o m*/
public class Main {

  public static void main(String[] args) {

    int[] numbers = {2, 3, 5, 7, 11, 13};
    IntStream intStream = Arrays.stream(numbers);
    intStream = intStream.limit(3);
    System.out.println(intStream.sum());
  }

}

The code above generates the following result.





















Home »
  Java Streams »
    Examples »




Average
Filter
Group
IntStream
Map
Partition
Reduce
Sort
Sum