How to convert Map to Map ? (option : using guava)

前端 未结 6 867
礼貌的吻别
礼貌的吻别 2020-12-10 01:16

I have a Map the String key is nothing but numeric value like \"123\" etc. I\'m getting numeric value because this values are

6条回答
  •  执笔经年
    2020-12-10 01:55

    You can now use Java 8 stream, map, collect to do this in a more readable, clean manner.

    Map oldMap
    
    Map newMap = oldMap.entrySet().stream()
      .collect(Collectors.toMap(entry -> Long.parseLong(entry.getKey()), Map.Entry::getValue));
    

提交回复
热议问题