thinking of the way implementing the Iterable interface lets clients iterate over something in your class with a foreach loop, is there a way to allow object comparison by <, > == etc.? It seems almost obvious to let the Comparable interface allow for this, but as far as I can tell, it doesn't.
不幸的是,由于Java不支持运算符重载,因此无法执行此操作。
it is trivial to translate a<b
to a.compareTo(b)<0
but there is no option for operator overloading
not to mention how would the nulls be handled
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.