What is factory method??
Factory design pattern in Java one of the core design
pattern which is used heavily not only in JDK but also in
various Open Source framework such as Spring, Struts and
Apache along with decorator design pattern in Java.
Factory Design pattern is based on Encapsulation object
oriented concept. Factory method is used to create
different object from factory often refereed as Item and it
encapsulate the creation code. So instead of having object
creation code on client side we encapsulate inside Factory
method in Java . One of the best examples of factory
pattern in Java is BorderFactory Class of Swing API.