Flattening a collection
Say I have a Map<List<String>>
I can get the values of the map easily enough, and iterate over it to
produce a single List<String>.
for (List<String> list : someMap.values()) {
someList.addAll(list);
}
Is there a way to flatten it in one shot?
List<String> someList = SomeMap.values().flatten();
No comments:
Post a Comment