public interface Prototype {
public Object cloneObject();
}
public class ConcretePrototype implements Prototype {
@Override
public Object cloneObject() {
// TODO Auto-generated method stub
return new ConcretePrototype();
}
}
public class Client {
private Prototype prototype;
public Client(Prototype prototype) {
this.prototype = prototype;
}
public Prototype getPrototype() {
return prototype;
}
public void setPrototype(Prototype prototype) {
this.prototype = prototype;
}
public static void main(String[] args) {
Client c = new Client(new ConcretePrototype());
c.getPrototype().cloneObject();
}
}
Highly recommended blog for learning design patterns: java_my_life
Code address: lennon