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…


Prepare to fast-track & go places

Answers are detailed to be useful beyond job interviews. A few Q&As each day will make a huge difference in 3 to 24 months depending on your experience.
Top