Java8 stream 提取对象 List 中的某一字段生成新的 List
作者:互联网
//输出List StudentInfo.printStudents(studentList); //从对象列表中提取一列(以name为例) List<String> nameList = studentList.stream().map(StudentInfo::getName).collect(Collectors.toList()); //提取后输出name nameList.forEach(s-> System.out.println(s));
标签:nameList,name,stream,List,studentList,一字段,StudentInfo 来源: https://www.cnblogs.com/yelanggu/p/15543270.html