Prototype Pattern in Java

By | July 4, 2020

In this post, We will talk and learn about Prototype Pattern in Java.

Prototype comes under a creational design pattern that makes use of cloning objects if object creation complex and time-consuming.

Below is the complete source code:

Student.java Model class

StudentDAO.java creates Cloned Object that makes use of  Prototype Pattern:

Test.java Client Program:

Output of this program:

Original Student List::
Student [Student id=10, Student name=PK]
Student [Student id=20, Student name=MK]
Updated Student List::
Student [Student id=10, Student name=PK]
Student [Student id=20, Student name=MK]
Student [Student id=30, Student name=SK]

That’s all about Prototype Pattern in Java

You May Also Like:

Singleton Pattern
Factory Pattern
Abstract Factory Pattern
Builder Pattern

If you have any feedback or suggestion please feel free to drop in below comment box.

One thought on “Prototype Pattern in Java

Leave a Reply

Your email address will not be published. Required fields are marked *