惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园_首页
雷峰网
雷峰网
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
WordPress大学
WordPress大学
腾讯CDC
T
Tailwind CSS Blog
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
The Cloudflare Blog
D
DataBreaches.Net
Recent Announcements
Recent Announcements
Engineering at Meta
Engineering at Meta
B
Blog
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
月光博客
月光博客
博客园 - 司徒正美
MongoDB | Blog
MongoDB | Blog
Google DeepMind News
Google DeepMind News
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - microtea

Jmeter多机联合产生负载 (转) 【转载】关于Java文件路径问题 - microtea - 博客园 安装CVSNT UTF-8的繁体与简体转换 - microtea - 博客园 利用MSSQL sp自制未公开的加密函数(转) wap开发的点小经验 no suitable driver java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]对象名 'xxx' 无效 关于临时表的个人经验 - microtea - 博客园 在Redhat9上安装Oracle 9.2 SQL中的单记录函数 常用javascript Java:int 和 String 互相转换的多种方法 JAVA:Duplicate name in Manifest: Class-Path 关于The underlying connection was closed ServerVariables 集合环境变量列表 初步的对防盗连接的方法的设想 在asp.net中对web.config内容的添加 Asp.net(C#)中基于Forms验证的角色(用户组)验证授权过程
java的对像克隆
microtea · 2005-09-23 · via 博客园 - microtea

public class Sheep implements Cloneable{
private String name;
public void setName(String arg) {
name 
= arg;
}

public String getName() {
return name;
}

public Object clone() throws CloneNotSupportedException {
return super.clone();
}

}

//克隆
public class Main {
public static void main(String[] args) throws CloneNotSupportedException {
Sheep sheep 
= new Sheep(); //先得到那只羊的实例
sheep.setName("我是真的"); //给它做个记号
System.out.println("sheep.getName() = " + sheep.getName());
Sheep sheepClone 
= (Sheep)sheep.clone(); //开始克隆
System.out.println("sheepClone.getName() = " + sheepClone.getName());
}

}
 


//运行程序结果为:
//sheep.getName() = 我是真的
//sheepClone.getName() = 我是真的