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:



Comments

Popular posts from this blog

Gove confirms mandatory housebuilding targets for councils will be abolished in face of Tory rebellion – UK politics live

Kotak Mahindra Bank Recruitment 2022 Released for Graduate Candidates And Apply Online