热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_56112712
Lee good
3 年前
trueweixin_56112712

第一次发帖,记录一下自己的学习
关于Java当中的 map.putAll()方法总结
原码如下
import java.util.HashMap;
import java.util.Map;
public class mapDemo {
public static void main(String[] args) {
Map<String,Integer>maps=new HashMap<>();
Map<String,Integer>maps1=new HashMap<>();
maps.put("鸿星尔克",2);
maps.put("阿迪达斯",3);
maps.put("耐克",100);
maps1.putAll(maps);
maps.remove("鸿星尔克");
System.out.println("原始内容"+maps);
System.out.println("新始内容"+maps1);

}
}
运行情况如图所示
得出putAll()方法是一种深拷贝

CSDN App 扫码分享
分享
评论
1
打赏
  • 复制链接
  • 举报
下一条:
大梦想家!
立即登录