Design Pattern: Strategy Design Pattern in Java with Example in JDK

Strategy design pattern is one of the behavioral design pattern. Strategy pattern is used when we have multiple algorithm for a specific task and client decides the actual implementation to be used at runtime. Strategy pattern is also known as Policy Pattern.

One of the best example of strategy pattern is

Collections.sort(anyCollection, Comparator implemetation)

 method that takes Comparator parameter. Based on the different implementations of Comparator interfaces, the Objects are getting sorted in different ways.


Strategy Design Pattern


You may also like

Leave a Reply

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