Java/Comparable: Difference between revisions
From charlesreid1
(Created page with "Comparable is the interface that is implemented in order for objects to be comparable using operators like < > == etc. https://docs.oracle.com/javase/8/docs/api/java/lang/Com...") |
No edit summary |
||
| Line 1: | Line 1: | ||
{{Main|Java/Comparators}} | |||
Comparable is the interface that is implemented in order for objects to be comparable using operators like < > == etc. | Comparable is the interface that is implemented in order for objects to be comparable using operators like < > == etc. | ||
Revision as of 01:43, 11 June 2017
Main article: Java/Comparators
Comparable is the interface that is implemented in order for objects to be comparable using operators like < > == etc.
https://docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html
This is a generic type interface, and can be used to define a class that can be compared using custom criteria. For example, we can organize a list according to a very specific method of ordering (right-to-left, filling in with "ghost" titles, as in the Classy problem), or according to custom criteria like when a Cartesian (x,y) point would be visited by a space-filling curve, as with the Hilbert Sort problem.