Java DoubleSummaryStatistics class
import java.time.LocalDate; import java.time.Month; import java.util.Arrays; import java.util.DoubleSummaryStatistics; import java.util.List; public class Main { public static void main(String[] args) { DoubleSummaryStatistics stats = new DoubleSummaryStatistics(); stats.accept(12345.1);/*from ww w. j a va2 s . c om*/ stats.accept(23456.2); stats.accept(34567.3); stats.accept(45678.4); stats.accept(56789.5); long count = stats.getCount(); double sum = stats.getSum(); double min = stats.getMin(); double avg = stats.getAverage(); double max = stats.getMax(); System.out.printf( "count=%d, sum=%.2f, min=%.2f, average=%.2f, max=%.2f%n", count, sum, min, max, avg); } }