使用Java流创建具有动态值的员工列表
问题描述:
我有一个用例,其中我必须创建ID递增的默认雇员列表,
I have use case where I have to create List of default employees with incrementing id,
List<Employee> employeeList = new ArrayList<>();
int count = 0;
while (count++ <= 100){
Employee employee = new Employee(count, "a"+count);
employeeList.add(employee);
}
我没有可以使用流的任何收藏.我们可以通过功能方式做到吗?
I don't have any collection on which I could use stream. Can we do it in functional way?