Science, asked by MissIncredible34, 23 hours ago

Difference between comparator and comparable with an example?​​

Answers

Answered by radhyashukla123
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 chocolateyqueen15
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