Convert Map to Map

后端 未结 11 1942
暗喜
暗喜 2021-01-31 13:27

How can I convert Map to Map ?

This does not work:

Map map = ne         


        
11条回答
  •  轮回少年
    2021-01-31 14:02

    Use the Java 8 way of converting a Map to Map. This solution handles null values.

    Map keysValuesStrings = keysValues.entrySet().stream()
        .filter(entry -> entry.getValue() != null)
        .collect(Collectors.toMap(Entry::getKey, entry -> entry.getValue().toString()));
    

提交回复
热议问题