package com.shrimpking.t3;
import java.util.Arrays;
import java.util.IntSummaryStatistics;
import java.util.List;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/11 16:57
*/
public class StatStream
{
public static void main(String[] args)
{
List<Integer> list = Arrays.asList(1,2,5,4,7,3,5,2,6);
IntSummaryStatistics statistics = list.stream()
.mapToInt( x -> x)
.summaryStatistics();
System.out.println("列表中元素的数目=" + statistics.getCount());
System.out.println("列表中最大的数=" + statistics.getMax());
System.out.println("列表中最小的数=" + statistics.getMin());
System.out.println("列表中所有数之和=" + statistics.getSum());
System.out.println("列表中数的平均值=" + statistics.getAverage());
}
}
标签:statistics,StatStream,System,列表,println,java,out
From: https://blog.51cto.com/u_15356972/12016826