Java Streams - IntStream of(int... values) example








IntStream of(int... values) returns a sequential ordered stream whose elements are the specified values.

Syntax

of has the following syntax.

static IntStream of(int... values)

Example

The following example shows how to use of.

import java.util.stream.IntStream;

public class Main {
  public static void main(String[] args) {
    IntStream i = IntStream.of(6,5,7,1, 2, 3, 3);
    long d = i.count();
    System.out.println(d);
  }
}

The code above generates the following result.