I am trying to concat list of a stream and process it.
class A {
    public List<B> bList;
}
List<A> aList;
aList.stream().map(a -> a.bList)....
Here i get several list of b.
But, I would like to collect all my b in only one list. Any ideas ?
I am trying to concat list of a stream and process it.
class A {
    public List<B> bList;
}
List<A> aList;
aList.stream().map(a -> a.bList)....
Here i get several list of b.
But, I would like to collect all my b in only one list. Any ideas ?
 
    
     
    
    That's what flatMap is for :
List<B> bList = aList.stream()
                     .flatMap(a -> a.bList.stream())
                     .collect(Collectors.toList());
