I have the following collection type:
Map> map;
I would like to create unique combinations of each o
In loop create combined list
List cartesianProduct(List> wordLists) {
List cp = wordLists.get(0);
for (int i = 1; i < wordLists.size(); i++)
{
List secondList = wordLists.get(i);
List combinedList = cp.stream().flatMap(s1 -> secondList.stream().map(s2 -> s1 + s2))
.collect(Collectors.toList());
cp = combinedList;
}
return cp;
}