IntStream of(int... values) example

Description

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;
/*from  w  w  w . jav a  2s.  co  m*/
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.





















Home »
  Java Streams »
    Reference »




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