A Strategy Pattern says that "defines a family of functionality, encapsulate each one, and make them interchangeable".
The Strategy Pattern is also known as Policy.
Strategy Pattern in (Core Java API's) or JSE 7 API's:
Strategy Pattern in (Advance Java API's) or JEE 7 API's:
UML for Strategy Pattern:
Implementation of Strategy Pattern:
Create a Strategy interface.
Create a Addition class that will implement Startegy interface.
Create a Subtraction class that will implement Startegy interface.
Create a Multiplication class that will implement Startegy interface.
Create a Context class that will ask from Startegy interface to execute the type of strategy.
Create a StartegyPatternDemo class.