Comparable vs Comparator

Comparable and Comparator both the interfaces are used to sort Collection of objects in certain order. Implementing Comparable interface allows us to achieve default or natural ordering where implementing a Comparator allow us to sort Collection in other than natural ordering.   Comparable interface imposes a total ordering on the objects of each class that … More Comparable vs Comparator

Functional Interface in Java

In Java, functional interfaces are those interfaces who has exactly one abstract method.  @FunctionalInterface is not a mandatory annotation to be used to make any interface a Functional Interface. Its just an informative annotation type used to indicate that an interface type declaration is intended to be a functional interface. Since default methods have an implementation, they are … More Functional Interface in Java

Factory Design Pattern

Factory design pattern belong to the Creational design pattern category which explain how the objects are created. Factory Design Pattern comes with different flavors and we use the flavor as per our convenience. The very common example of Factory design pattern can be found in Spring. Creation of beans in Spring container is done using … More Factory Design Pattern

Strategy Design Pattern

This is kind of Behavioral Design Pattern(BDP) and as per the BDP definition, “Behavioral patterns describe how the objects behave when they interact with each other” and this design pattern is used when we have number of options to choose our strategy among available strategies. Example: Lets say you have one List of Employees which you want … More Strategy Design Pattern