package Stream ; import java . util . ArrayList ; import java . util . Collections ; import java . util . List ; /** * @Author yqq * @Date 2021/10/17 13:40 * @Version 1.0 */ public class demo01 { public static void main ( String [] args ) {
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @Author yqq
* @Date 2021/10/17 13:40
* @Version 1.0
*/
public class demo01 {
public static void main(String[] args) {
List<Student> list = new ArrayList<>();
Collections.addAll(list,
new Student("lishi",22,20),
new Student("zhangshan",23,28),
new Student("wanger",24,19),
new Student("mazi",25,29),
new Student("mazi",25,29)
);
System.out.println(list.stream().mapToInt(Student::getAge).average().getAsDouble());//23.8
}
}