java8新特性Lambda(4)

2020-12-13 03:48

阅读:403

标签:lambda   public   数据   remove   new   新特性   ola   stat   zhang   

import java.util.ArrayList;
import java.util.List;

import com.test.lambda.Person.Sex;

public class Lambda03 {

    public static void main(String[] args) {
        List list = new ArrayList();
        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);
        
    }
}

java8新特性Lambda(4)

标签:lambda   public   数据   remove   new   新特性   ola   stat   zhang   

原文地址:https://www.cnblogs.com/zzlcome/p/11089217.html


评论


亲,登录后才可以留言!