Java IntStream summary statistics
import java.util.IntSummaryStatistics; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { int[] values = { 3, 10, 6, 1, 4, 28, 22, 54, 95, 67 }; // display original values System.out.println("Original values: "); IntStream.of(values).forEach(value -> System.out.printf("%d ", value)); /*from w w w . j a v a 2 s . com*/ IntSummaryStatistics s = IntStream.of(values).summaryStatistics(); System.out.println(); System.out.println(s.getAverage()); System.out.println(s.getCount()); System.out.println(s.getSum()); System.out.println(s.getMax()); System.out.println(s.getMin()); } }