新建一个集合
List<Bill> billList = new ArrayList<>();
将订单中所有物品的名称提取出来做一个集合
List<String> goodsNameList = billList.stream().map(Bill::getGoodsName).collect(Collectors.toList());
补充:java8 lamada 提取集合中每个对象的属性
中台项目中:
MelotPageResult questionRelas = questionStudentRelaBiz.queryByParam(param); List questionIds = questionRelas.getList().stream().map(QuestionStudentRela::getQuestionId).collect(Collectors.toList());
百度的:
List students = new ArrayList();
往list里插入对象后
List names =students.stream().map(Student::getName).collect(Collectors.toList());
以上为个人经验,希望能给大家一个参考,也希望大家多多支持免费资源网。如有错误或未考虑完全的地方,望不吝赐教。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)