import java.util.*;
class Person implements Cloneable
{
        public String name;
 public Person(String name){
      this.name=name;
 } public String toString(){
 return this.name;
}public Object clone()
                throws CloneNotSupportedException
{
return super.clone();
}
}public class Test2{
      public static void main(String[] args) throws Exception {                          Person p1=new Person("jack");
                                       
                          Person p2=(Person)p1.clone();
                          p2.name="lucy";                          System.out.println(p1);
                          System.out.println(p2);           
                                                   
  }
}/*
对象克隆:
     实际上就是对象的复制。
要完成克隆的类必须具备以下两个条件:
1、类必须实现Cloneable接口,表示可以被克隆
2、类必须覆盖Object类中的clone方法。
*/