Java 8 Comparator Example Using Lambda Expressions

In short, You can implement Comparator using lambda expression because it is a SAM type interface. It just got one abstract method compare() which means you can pass lambda expression where a Comparator is expected. Many Java programmer often ask me, what is the best way to learn lambda expression of Java 8? Of course by using it on your day to day programming task. Since implementing equals(), hashcode(), compareTo(), and compare() methods are some of the most common tasks of a Java developer, it makes sense to learn how to use the lambda expression to implement Comparable and custom Comparator in Java. One question comes to mind, can we use lambda expression with Comparator? because it's an old interface and may not implement functional interface annotated with @FunctionalInterface annotation?
Read more »