Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses
http://javapapers.com/design-patterns/factory-method-pattern/
Assume that you have a set of classes which extends a common super class or interface. Now you will create a concrete class with a method which accepts one or more arguments. This method is our factory method. What it does is, based on the arguments passed factory method does logical operations and decides on which sub class to instantiate.
Application
Also refer to http://sourcemaking.com/design_patterns/factory_method
Read full article from Design Patterns Uncovered: The Factory Method Pattern | Javalobby
http://javapapers.com/design-patterns/factory-method-pattern/
Assume that you have a set of classes which extends a common super class or interface. Now you will create a concrete class with a method which accepts one or more arguments. This method is our factory method. What it does is, based on the arguments passed factory method does logical operations and decides on which sub class to instantiate.
Application
public
class
PetFactory {
public
Pet getPet(String petType) {
Read full article from Design Patterns Uncovered: The Factory Method Pattern | Javalobby