If I have a class Person
that implements Comparable
(compares personA.height
to personB.height
, for example), is it possible to use
personA < personB
as a substitute for
personA.compareTo(personB) == -1?
Are there any issues in doing this or do I need to overload operators?
There is no operator overloading in Java. You probably come from a C++ background.
You have to use the compareTo
method.