Java Relational Operators

In Java, which interface (class) should implement the class (extend) to allow two instances of the class to be comparable through relational operators like "<" or "> ="?

+4
source share
2 answers

In Java, this is not possible.

If you want the objects of your class to be comparable, run Comparable .

+11
source

Java does not support operator overloading, so you're out of luck. Implementing java.lang.Comparable or providing java.util.Comparator is what you should be doing.

+4
source

All Articles