日期:2014-05-20 浏览次数:20699 次
package prototype; public abstract class AbstractPerson implements Cloneable{ @Override protected Object clone() { Object obj=null; try { obj= super.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } return obj; } public abstract void canSpeak(); }
package prototype; public class Person extends AbstractPerson{ @Override public void canSpeak() { System.out.println("i can speack.."); } }
package prototype; public class Client { public static void main(String[] args) { AbstractPerson ap=new Person(); AbstractPerson ap2=null; ap2=(Person)ap.clone(); System.out.println(ap2.equals(ap)); } }