import java.util.ArrayList; import java.util.List; import com.test.lambda.Person.Sex; public class Lambda03 { public static void main(String[] args) { List<Person> list = new ArrayList<Person>(); Person p1 = new Person("zhangsan",Sex.MALE,1); Person p2 = new Person("lisi",Sex.MALE,1); Person p3 = new Person("lisi",Sex.MALE,2); Person p4 = new Person("xiaolan",Sex.FEMALE,3); Person p5 = new Person("xiaolan",Sex.FEMALE,3); Person p6 = new Person("xiaolan",Sex.FEMALE,3); list.add(p1); list.add(p2); list.add(p3); list.add(p4); list.add(p5); list.add(p6); list.removeIf(n->Sex.MALE.equals(n.getSex())&&2==n.getAge());//移除男性并且年龄2的数据 System.out.println(list); } }