Kamis, 29 Juli 2021

How to use Comparator and Comparable in Java? With example

Comparator and Comparable in Java Examples
The difference between Comparator and Comparable in Java is very popular Java interview question mostly asked in the telephonic rounds and writing code to sort objects using Comparable or Comparator is popular on the written test round of interviews. The question was this “How you will sort Employee object based on his EmployeeID and his name” and this involves the use of both Comparable as well as Comparator interface in Java. This post is my revision on Java fundamentals similar to what I did about the equals method in Java and some tips to override hashCode in Java. 

Lorem ipsum is simply dummy text of the printing and typesetting industry.

Comments


EmoticonEmoticon