package com.zhangxueliang.demo;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
public class Lambda_Stream_Demo {
public static void main(String[] args){
//method1();
List list = createStudent();
double d = list.stream()
.filter(s->s.getName().indexOf("张")>=0)
.mapToDouble(s->s.getAge())
.average()
.getAsDouble();
System.out.println("包含张字的所有人的平均年龄为:"+ d);
}
private static void method1() {
List list = createStudent();
Stream stream = list.stream();
stream.filter(s->s.getGender()==Student.Sex.FEMALE).forEach(s->System.out.println(s.toString()));
}
public static List createStudent(){
Student s1 = new Student("张三",16,Studen