convert map to list - as “key-value” to each list entry

后端 未结 4 1166
Happy的楠姐
Happy的楠姐 2021-01-14 09:16

I want to convert Map to List with each map entry - to 1 entry in the list as \"key - value\"

I search

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-14 09:40

        List list = map.entrySet()
                                .stream()
                                .map(entry -> entry.getKey() + "-" + entry.getValue())
                                .sorted()
                                .collect(Collectors.toList());
    

提交回复
热议问题