If I implement java.lang.Comparable
for a class, do I still have to override the equals()
method? Or will the Comparable
work for equals
as well?
If the answer is no, then what if some discrepancy arises? Let's say the way I term two objects as equal within the equals()
method is different from the way I term two objects of the same class as equal within the compareTo()
of the Comparable
.
Moreover, if I implement Comparable
, do I also have to override equals()
?