1

I have a map of List for custom wrapper object records as below

Map<String, List<Custom wrapper object>>

I want to get all the records in one list together irrespective of the key of map.

How can this be achieved?

9

It's a pretty simple structure to flatten.

List<MyWrapper> flattened = new List<MyWrapper>();
for (List<MyWrapper> collection : myMap.values())
    flattened.addAll(collection);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.