lamba统计最大值,最小值,平均值,总和,个数

代码如下:

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());

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-07-03
  • 2021-11-28
相关资源
相似解决方案