怪兽啊

导航

java中用stream进行取值

 

举个例子Student类中有name属性:

List<Student> students = new ArrayList<Student>();

List<String> names =students.stream().map(Student::getName).collect(Collectors.toList());

 

其中getName是要在student中要去出的属性值,

左后将该值的结果返回一个集合

posted on 2021-10-20 16:26  怪兽啊  阅读(727)  评论(0编辑  收藏  举报