There is a simply:
public class Task{
private String name;
private List<Task> subtasks;
}
and a list of Task
objects. How is it possible to get list of every Task
as subtask
by using stream()
.
I tried this one:
List<Task> subtasks = myTask.stream().map(x -> x.getSubtasks()).collect(Collectors.toList());
but it returns List<List<Task>>
. What is the best way to join array from map()
to existing result?