【问题标题】:how to convert List<Map<String, String>> into the list containing the values of the map in java8如何将 List<Map<String, String>> 转换为包含 java8 中地图值的列表
【发布时间】:2023-01-17 15:51:08
【问题描述】:

List<Map<String,String>> - 这是给定的

我想获取地图的值列表。

【问题讨论】:

    标签: java collections stream


    【解决方案1】:

    如果我理解正确你的意思你可以做这样的事情:

    List<Map<String, String>> listOfMaps = ...;
    List<String> values = listOfMaps.stream()
        .flatMap(map -> map.values().stream())
        .collect(Collectors.toList());
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-01
      • 2016-07-21
      相关资源
      最近更新 更多