Bael-667 Flatten Nested Collections (#1330)
* article Bael-667 initial commit. * Switch to use logging framework for output.
This commit is contained in:
committed by
Zeger Hendrikse
parent
fb7b2c798c
commit
ea26d4209e
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.list.flattennestedlist;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FlattenNestedList {
|
||||
|
||||
public List<String> flattenListOfLists(List<List<String>> lol) {
|
||||
|
||||
// flatten the list
|
||||
List<String> ls = new ArrayList<>();
|
||||
lol.forEach((k) -> ls.addAll(k));
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user