IntStream count() example

Description

IntStream count() returns the count of elements in this stream.

Syntax

count has the following syntax.


long count()

Example

The following example shows how to use count.


import java.util.stream.IntStream;
/*from w  w  w . j a  v  a 2 s  . 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