代码如下:
List<Integer> ages = Arrays.asList(1,3,5,7,8,10,12); IntSummaryStatistics intSummaryStatistics = ages.stream().mapToInt(e -> e).summaryStatistics(); System.out.println("最大值: " + intSummaryStatistics.getMax()); System.out.println("最小值: " + intSummaryStatistics.getMin()); System.out.println("平均值: " + intSummaryStatistics.getAverage()); System.out.println("总和: " + intSummaryStatistics.getSum()); System.out.println("个数: " + intSummaryStatistics.getCount());