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);
    }

}

 

posted @ 2019-05-09 17:33  杨树清木  阅读(1308)  评论(0)    收藏  举报