stock market

Factory Design Pattern in Java for Beginners

Spread the love

The Factory Design Pattern is a creational design pattern used to create objects without exposing the object creation logic to the client. Instead of using the new keyword directly, the client relies on a factory method to get the required object.

Factory Design pattern is used when we have a super class with multiple subclass and based on input , we return the one of the subclasses .

Super class in factory pattern can be an interface , abstract class ,or a normal java class .

Example : Computer.java

Pc.java

Server.java

ComputerFactory.java

TestFactoryMain.java

Leave a Reply

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