1. Overview
In this tutorial, We'll learn how to use the Comparator interface with lambda expression in Java 8 onwards.
Lambda expression is to replace the anonymous implementations and to reduce the boilerplate code.
This makes the code cleaner and focus more on the business logic rather than semantics.
Look at the few examples before and after java 8 using Lambda expressions.
Java community provided a few sets of rules and guidelines in creating the lambda statements.
Lambda syntax and invalid one are discussed in detail in the previous discussions "java 8 lambda expressions".
First, we will see the examples without lambda and then the next section will see the equivalent lambdas.
For sorting to work with lambda comparator, we have to use the Collections.sort() method.