SoFunction
Updated on 2025-03-08

Java8 implements extracting each attribute of a collection object

Create a new collection

List<Bill> billList = new ArrayList<>();

Extract the names of all items in the order to make a collection

List<String> goodsNameList = ().map(Bill::getGoodsName).collect(());

Supplement: java8 lamada extracts properties of each object in the collection

Middle office projects:

MelotPageResult questionRelas = (param);
List questionIds = ().stream().map(QuestionStudentRela::getQuestionId).collect(());

Baidu:

List students = new ArrayList();

After inserting the object into the list

List names =().map(Student::getName).collect(());

The above is personal experience. I hope you can give you a reference and I hope you can support me more. If there are any mistakes or no complete considerations, I would like to give you advice.