I have the following situation
Map map;
public class ListContainer{
List lst;
}
I have to merge
Alternative: Stream.concat()
Stream.concat(map.values().stream(), listContainer.lst.stream())
.collect(Collectors.toList()
In Java 8 we can use stream List1.stream().collect(Collectors.toList()).addAll(List2); Another option List1.addAll(List2)
I think flatMap() is what you're looking for.
For example:
List<AClass> allTheObjects = map.values()
.stream()
.flatMap(listContainer -> listContainer.lst.stream())
.collect(Collectors.toList());