Java里面的对象克隆计算机等级考试
文章作者 100test 发表时间 2010:01:01 12:27:55
来源 100Test.Com百考试题网
java里面的对象克隆:实际存在的对象拷贝几份!
即将一个实际的对象进行多份拷贝
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
package xsocket.server.
public class Test implements Cloneable {
private String name.
public void setName(String arg) {
this.name = arg.
}
public String getName() {
return this.name.
}
public Object clone() throws CloneNotSupportedException {
return super.clone().
}
public static void main(String[] args) throws CloneNotSupportedException {
Test shepp = new Test().
shepp.setName("first").
System.out.println(shepp.getName()).
Test sheppclone = (Test)shepp.clone().