2018-02-08

package com.richard.lambdaexpressions;
import java.util.List;
public class Roster1 {
interface CheckPerson{
public boolean test(Person p);
}
public static void printPersons(List roster,CheckPerson tester){
for(Person p:roster){
if(tester.test(p)){
p.printPerson();
}
}
}

public static void main(String[] args) {
    // TODO Auto-generated method stub
    List roster=Person.createRoster();
    
    printPersons(roster,
            (Person p)->p.getGender()==Person.Sex.MALE &&
            p.getAge()>=20 &&
            p.getAge()<=30);
    printPersons(roster,
            (Person p)->p.getBirthday().toString().equals("1975-10-21"));
}

}

你可能感兴趣的:(2018-02-08)