简体   繁体   中英

how to convert List<Map<String, String>> into the list containing the values of the map in java8

List<Map<String,String>> - this is given

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

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());

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM