=\"?This" />
开发者

Java relational operators

In Java, what interface(class) should a class implement(extend) in order to allow two in开发者_Python百科stances of the class to be comparable through relational operators like "<" or ">="?


This is not possible in Java.

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


Java does not support operator overloading, so you're out of luck. Implementing java.lang.Comparable or providing a java.util.Comparator is what you're supposed to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜