Java Streams - IntStream summaryStatistics() example








IntStream summaryStatistics() returns an IntSummaryStatistics describing various summary data about the elements of this stream.

Syntax

summaryStatistics has the following syntax.

IntSummaryStatistics summaryStatistics()

Example

The following example shows how to use summaryStatistics.

import java.util.IntSummaryStatistics;
import java.util.stream.IntStream;
/* w  w w  .j  a v a  2s .  c  o  m*/
public class Main {
  public static void main(String[] args) {
    IntStream i = IntStream.of(6,5,7,1, 2, 3, 3);
    IntSummaryStatistics s = i.summaryStatistics();
    System.out.println(s);
  }
}

The code above generates the following result.