新建一个集合

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());

以上为个人经验,希望能给大家一个参考,也希望大家多多支持www.887551.com。如有错误或未考虑完全的地方,望不吝赐教。