How to sort objects in java using Comparator?

In the below example class Student has three fields

Name, Age & Mark

Now i am showing 2 types of sorting here

  1. by Name
  2. by Mark
Comparator is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference. This interface is a member of the Java Collections Framework.


Output:



No comments:

Post a Comment