2

Given: a List<Map<String,String>>.

I want to get List<String> of values of the map.

2 Answers 2

5

If I understand correctly what you mean you can do something like this :

List<Map<String, String>> listOfMaps = ...;
List<String> values = listOfMaps.stream()
    .flatMap(map -> map.values().stream())
    .collect(Collectors.toList());
Sign up to request clarification or add additional context in comments.

Comments

-1
List<String> valuesList = new ArrayList<>(yourmap.values());

https://www.tutorialspoint.com/Java-program-to-convert-the-contents-of-a-Map-to-list

1 Comment

This converts a Map< String, String> to a List<String>. The question is how to convert a List<Map<String, String>> to a List<String>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.