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.net.URLStreamHandlerFactory.createURLStreamHandler(String)
  • 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()
Read the full book at www.amazon.com
Posted in Design Pattern, Design Pattern Interview Questions

Leave a Reply

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

*