Physics, asked by JuSTYoURxXRiJITXx, 1 day ago

Difference between comparator and comparable with an example?​

Answers

Answered by deepak9140
7

Explanation:

A comparator interface is used to order the objects of user-defined classes. A comparator object is capable of comparing two objects of two different classes. Following function compare obj1 with obj2. Syntax: Attention reader

A comparator interface is used to order the objects of user-defined classes. A comparator object is capable of comparing two objects of two different classes. Following function compare obj1 with obj2. Syntax: Attention reader

capable of or suitable for comparison The situations are not at all comparable. 2 : similar, like fabrics of comparable quality The two houses are comparable in size. Other Words from comparable Synonyms & Antonyms More Example Sentences Learn More About comparable.An example of comparison is tasting different years of pinot noir wine back to back and discussing their differences. noun. 55. 15.

Answered by simmirawat85
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

Explanation:

please mark my answer brainlieast

Similar questions