Map.putAll()的用法
来源:互联网 发布:淘宝怎么成为大v 编辑:程序博客网 时间:2024/06/14 08:59
public void test4(){ Map<String, Object> retMap2 = new HashMap<String, Object>(); retMap2.put("id","2"); retMap2.put("name","xuesiyuan"); retMap2.put("parents","FatherAndMother"); Map<String, Object> retMap = new HashMap<String, Object>(); retMap.put("id","1"); retMap.put("name","xsy"); retMap.put("age","22"); retMap.put("sex","man"); retMap2.putAll(retMap);// System.out.println(retMap2.get("id")+" "+retMap2.get("name")+" "+retMap2.get("age")+" "+retMap2.get("sex")+" "+retMap2.get("parents")); }
Run:1 xsy 22 man FatherAndMother如果new一个Map使用此方法,很容易理解为复制,但是不是,实际上是合并
.putAll(Map)意思是合并两个Map,如果有相同的Key时,后面的Map覆盖前面的Key和Value
阅读全文
0 0
- Map.putAll()的用法
- Map.putAll()用法
- Map.putAll()用法
- Map.putAll()用法
- Map.putAll()用法
- Map.putAll()用法
- Map的赋值和putAll的区别
- Map集合的putAll()方法的使用。
- java中关于Map的三种遍历方法机putAll的用法详解
- Map.putall()方法
- Map.putAll() 使用方法 简单易懂
- Map.putAll(Map<? extends String, ? extends Object> m)方法
- Map.putAll方法——追加另一个Map对象到当前Map集合
- 关于map的用法
- map的用法
- STL的map用法
- STL的map用法
- STL的map用法
- Apache windows 配置一个 IP 绑定多个域名
- dl4j的BaseLayer前向与反向传播算法计算过程简介
- Python 2.7 拾遗(3)
- try-with-resources资源自动释放特性
- 菜鸡日常刷CF # 452DIV2 前三题
- Map.putAll()的用法
- FFmpeg常用命令集合
- 修改包名Xcode
- OpenGL: 模板缓冲区的理解
- 程序员 30 岁前,该如何规划自己的职业发展?
- dubbo2.5.3注解版
- 规则引擎
- mysql
- 共享内存通信