Difference between comparator and comparable with an example?
Answers
Answered by
5
Explanation:
Comparable is meant for objects with natural ordering which means the object itself must know how it is to be ordered. For example Roll Numbers of students. ... Logically, Comparable interface compares “this” reference with the object specified and Comparator in Java compares two different class objects provided.
Answered by
2
Answer:
Comparable is meant for objects with natural ordering which means the object itself must know how it is to be ordered. For example Roll Numbers of students. ... Logically, Comparable interface compares “this” reference with the object specified and Comparator in Java compares two different class objects provided.
Similar questions