Can you tell some examples of Factory Method design pattern implementation in Java?

Factory Method pattern is a creational design pattern. A Factory is an object that is used to create more objects.

In general, a Factory object has methods that can be used to create a type of objects. Some people call it Factory Method design pattern as well.

Some of the examples of Factory Method pattern in JDK are:

  • Java.lang.Class.forName()
  • java.util.Calendar.getInstance()
  • java.util.ResourceBundle.getBundle()
  • java.text.NumberFormat.getInstance()
  • java.nio.charset.Charset.forName()
  • java.util.EnumSet.of()
  • javax.xml.bind.JAXBContext.createMarshaller()

Leave a Reply

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