Java8-Lomda表达式


Lomda表达式

/**  
 * All rights Reserved, Designed By www.bingo.com
 * @Title TestLamda.java     
 * @author yang          
 * @date 2019年4月18日 上午11:12:55   
 * @version V1.0 
 */
package com.yang;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeSet;

import org.junit.Test;

/**
 * @Package com.yang
 * @ClassName TestLamda
 * @Description TODO
 * @version v1.0.0
 * @author yang
 * @date 2019年4月18日上午11:12:55
 */
public class TestLamda {
    private static List<Employee> list = new ArrayList<>();
    static {

        list.add(new Employee(1, "zhangsan", 500.2, 18));
        list.add(new Employee(2, "zhangsan1", 5001.2, 78));
        list.add(new Employee(3, "zhangsan2", 1500.2, 48));
        list.add(new Employee(4, "zhangsan3", 7000.2, 28));
        list.add(new Employee(5, "zhangsan4", 6000.2, 38));
        list.add(new Employee(6, "zhangsan5", 8000.2, 25));
    }

    /**
     * stream api
     * 
     * @Function test02
     * @Description TODO
     * @version v1.0.0
     * @author yang
     * @date 2019年4月18日下午1:10:04
     */
    @Test
    public void test02() {
        list.stream().filter((e) -> e.getAge() > 30).limit(2).forEach(System.out::println);
    }

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM