How Java 8 lamada Stream: gets a collection of child attributes of an attribute

is like this. There is an order list List < order > whose order contains several goods. Now you want to get the id,model structure of all goods in the order list as follows:

class order {
int id,
List < goods > goodsList;
}
class goods {
int id;
String name;
}

List < order > list.
you can get the id list of the order. The question now is how to get the list of items under all the list orders,
list.stream (). Map (c-> c.getId ()). Orders (Collectors.toList ()) < order >.
the following words do not seem to be correct
list.stream (). Map (c-> c.getGoodsList (). Stream (). Map (Q-> q.getId (). Collect (Collectors.toList ());

Mar.14,2021

give it a try

list.stream()
    .map(order::getGoodsList)
    .flatmap(goods::getId)
    .map(x -> new Integer(x))
    .collect(Collectors.toList())

, note that List cannot be int and must be Integer


nested loops would be fine

orders.stream.map(order->{
      return
      order.getGoodList().map(good->{
               return good.getId();
       }).collect(Collectors.toList());
}).collect (Collectors.toList());
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3d93d-3476f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3d93d-3476f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?