how can I flatten a List<List<List<String>>>

Eya Behi :

I am trying to flatten a BigList :

List<List<List<String>>> input

example of my list

[[[a,b],[c,b]], [[x],[y]]]`

I want the result to be as follows :

[[a,b,c],[x,y]]

For the duplicates, I will try to use linkedhashset, but I can not flatten the list. Any help, please?

Eugene :
List<List<String>> result = 
    list.stream()
        .map(x -> x.stream()
                   .flatMap(List::stream)
                   .distinct()
                   .collect(Collectors.toList()))
        .collect(Collectors.toList());

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=300983&siteId=1