Java Streams - IntStream of(int t) example








IntStream of(int t) returns a sequential IntStream containing a single element.

Syntax

of has the following syntax.

static IntStream of(int t)

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(1);
    i.forEach(System.out::println);
  }
}

The code above generates the following result.