DoubleSummaryStatistics (Java SE 10 & JDK 10 ) (original) (raw)


public class DoubleSummaryStatistics
extends Object
implements DoubleConsumer
A state object for collecting statistics such as count, min, max, sum, and average.
This class is designed to work with (though does not require)streams. For example, you can compute summary statistics on a stream of doubles with:
DoubleSummaryStatistics stats = doubleStream.collect(DoubleSummaryStatistics::new, DoubleSummaryStatistics::accept, DoubleSummaryStatistics::combine);
DoubleSummaryStatistics can be used as areduction target for a stream. For example:
DoubleSummaryStatistics stats = people.stream() .collect(Collectors.summarizingDouble(Person::getWeight));
This computes, in a single pass, the count of people, as well as the minimum, maximum, sum, and average of their weights.
Implementation Note:
This implementation is not thread safe. However, it is safe to useCollectors.summarizingDouble() on a parallel stream, because the parallel implementation of Stream.collect() provides the necessary partitioning, isolation, and merging of results for safe and efficient parallel execution.
Since:
1.8

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.