Map集合中的同一键值key重复赋值

前言:

验证:对Map集合中的同一键值key重复赋值?
结果:对Map集合中的同一键值key重复赋值会覆盖之前的结果

验证如下:

Map<String, Object> map = new HashMap<String, Object>();
map.put("data", "99");
map.put("message", "victory");
map.put("info", "成功");
System.out.println("map的大小:"+map.size());
System.out.println("message:"+map.get("message"));
map.put("message", "defeat");
System.out.println("message:"+map.get("message"));

验证结果:

map的大小:3
message:victory
message:defeat

 

  

 

posted @ 2021-01-08 21:00  云村的王子  阅读(703)  评论(0编辑  收藏  举报