Convert List of List into list in java
superlist.forEach(e -> result.addAll(e));
Now after some reasarch, I found this way.
Try like this using flatMap
:
List<List<Object>> list =
List<Object> lst = list.stream()
.flatMap(Collection::stream)
.collect(Collectors.toList());
If you're on Java < 8 (and cannot use Stream
s), you can do this in a one-liner with Guava's Iterables.concat
:
List<String> merged = Lists.newArrayList(Iterables.concat(superList));