Java 8: Different ways to sort a collection of objects in pre and post Java 8

The object we are going to sort is a Person.

Option 1: Writing your own Comparator implementation. This can be done as an anonymous inner class instead of a separate class.

The test class

Option 2: The…

🔥 300+ Java Interview FAQs

Java & Big Data Tutorials