Hello my question is very similar to Java8: Stream map two properties in the same stream but for some reason I cannot get my code to work.
So like that question, say I have a class Model
class Model {
private List<Integer> listA;
private List<Integer> listB;
private List<Integer> listC;
public List<Integer> getListA() {
return listA;
}
public List<Integer> getListB() {
return listB;
}
public List<Integer> getListC() {
return listC;
}
}
So I want to combine these lists from a List<Model> myList
using a stream and my code looks like this:
myList.stream()
.flatmap(i -> Stream.of(i.getListA(), i.getListB(), i.getListC()))
.collect(Collectors.toList())
.get(0)
But this approach ends up returning an empty list. I would appreaciate any suggestions