package com.gp6.list.limit;
import com.gp6.bean.Employee;
import com.gp6.list.utils.ListUtil;
import java.util.List;
import java.util.stream.Collectors;
/**
* 测试list取指定前几条
*
* @author gp6
* @date 2019-07-23
*/
public class TestLimit {
public static void main(String[] args) {
List<Employee> employeeList = ListUtil.packEmployeeList();
// 取出列表中前两条
List<Employee> limitList = employeeList.stream().limit(2).collect(Collectors.toList());
limitList.forEach(employee -> {
});
}
}
网友评论