Prototype Design Pattern

Builder design pattern belongs to creational design pattern family and this Prototype design pattern is used when we dont want to use either the new operator or create another factory class. i.e. we clone existing objects to create new ones.

But How:  To implement the pattern, declare an abstract base class or interface that specifies a virtual clone() method. Any class that needs an object without using new operation, can derive itself from the abstract base class or interface and implements the clone() operation.

The client, instead of writing code that invokes the “new” operator on a hard-coded class name, calls the clone() method on the prototype invokes the clone() method through some mechanism provided by another design pattern.


public interface Prototype {
 public abstract Object clone ();

public class ConcretePrototype implements Prototype {
  public Object clone() {
   return super.clone();

public class Client {
  public static void main( String arg[] ) {
    ConcretePrototype obj1= new ConcretePrototype ();
    ConcretePrototype obj2 = ConcretePrototype)obj1.clone();

The another way to achieve this mechanism is to implement Cloneable interface and overriding clone() method from Object class.

Hope this clears your doubt!!

One thought on “Prototype Design Pattern

Comments are closed.