How do I continue the stream mapping after collect:
public Bus createBus(List<String> passengers) {
return passengers.stream()
.map(name -> new Person(name))
.collect(Collectors.toList())
.map(personList -> new Bus(personList))
}
Above obviously does not work. How to make it work elegantly without using any variables in the method body?
Edit: Constructor is Bus(List persons).