对象克隆技术
2013-07-18 11:02
351 查看
package org.lxh.demo11.demo;
class Person implements Cloneable{
private String name = null;
public Person(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public Object clone() throws CloneNotSupportedException{
return super.clone();
}
public String toString(){
return "name: "+this.getName();
}
}
public class Demo05 {
public static void main(String args[]) throws CloneNotSupportedException {
Person per1 = new Person("zhangsan");
Person per2 = (Person)per1.clone();
((Person) per2).setName("lisi");s
System.out.println("former:"+per1);
System.out.println("later :"+per2);
}
}
此字段最重要的语句:1、public Object clone() throws CloneNotSupportedException;
2、public static void main(String args[]) throws CloneNotSupportedException {
class Person implements Cloneable{
private String name = null;
public Person(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}
public Object clone() throws CloneNotSupportedException{
return super.clone();
}
public String toString(){
return "name: "+this.getName();
}
}
public class Demo05 {
public static void main(String args[]) throws CloneNotSupportedException {
Person per1 = new Person("zhangsan");
Person per2 = (Person)per1.clone();
((Person) per2).setName("lisi");s
System.out.println("former:"+per1);
System.out.println("later :"+per2);
}
}
此字段最重要的语句:1、public Object clone() throws CloneNotSupportedException;
2、public static void main(String args[]) throws CloneNotSupportedException {
相关文章推荐
- 【Java常用类库】_对象克隆技术笔记
- 对象克隆技术
- 对象克隆技术
- Java常用类库——对象克隆技术
- 对象克隆技术
- Java常用类库--对象克隆技术clone
- java常用类库---对象克隆技术
- java常用类库续2(大数操作BigInteger、BigDecimal类、对象克隆技术、Arrays类)
- java的对象克隆技术clone()之浅度克隆(shallow Clone)
- 11. JAVA常用类库 Part 4 (对象克隆技术clone、Arrays类、Comparable接口、比较器Comparator、观察者设计模式) ----- 学习笔记
- 【Java常用类库】_对象克隆技术笔记
- 对象克隆技术 clone()
- 《JAVA2核心技术 卷一 基础知识(原书第七版)》《Core java2,Volume I-Fondamentsls Seven Edition》 学习笔记(三)对象的克隆
- 对象克隆技术Object.clone()
- 掌握-----对象克隆技术
- 【笔记】java核心技术-对象的克隆
- 对象克隆技术
- 对象克隆技术
- 原型模式(Prototype)与Delphi对象克隆技术
- 面向对象语言的技术特点