Best understanding of Comparable & Comparator interfaces in Java.
One of the common java interview questions:
How to sort a collection of employee objects by employee id?
Also what to do if we want to sort it by employee name, too?
What are the differences between comparable & comparator interfaces?
How to sort collections using these interfaces?
What is the difference between Collection & Collections?
Before discussing about their differences let us see brief description about these two interfaces.