Java Streams - DoubleStream summaryStatistics() example








DoubleStream summaryStatistics() returns a DoubleSummaryStatistics describing various summary data about the elements of this stream.

Syntax

summaryStatistics has the following syntax.

DoubleSummaryStatistics summaryStatistics()

Example

The following example shows how to use summaryStatistics.

import java.util.DoubleSummaryStatistics;
import java.util.stream.DoubleStream;
//from w w  w  .  j  a  va 2s  .c  o  m
public class Main {
  public static void main(String[] args) {
    DoubleStream b = DoubleStream.of(1.1,2.2,3.3,4.4,5.5);
    DoubleSummaryStatistics d = b.summaryStatistics();
    System.out.println(d);
    
  }
}

The code above generates the following result.