I have the following code which could be much simpler using Java 8 stream API:
List<List<String>> listOfListValues;
public List<String> getAsFlattenedList() {
List<String> listOfValues= new ArrayList<>();
for (List<String> value: listOfListValues) {
listOfValues.add(String.valueOf(value));
}
return listOfValues;
}
I searched for a solution on SO and found this:
listOfListValues.stream()
.flatMap(List::stream)
.collect(Collectors.toList());
But this doesn't do the same what I want.