IntStream of(int t) example

Description

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;
/*from   w  ww. j  a  va 2 s . c o m*/
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.





















Home »
  Java Streams »
    Reference »




Collectors
DoubleStream
DoubleStream.Builder
IntStream
IntStream.Builder
LongStream
LongStream.Builder
Stream
Stream.Builder