pure.java pure.java - 1 month ago 8
Java Question

Why doesn't Java need Operator Overloading?

Why doesn't Java need operator overloading? Is there any way it can be supported in Java?

Answer

Java only allows arithmetic operations on elementary numeric types. It's a mixed blessing, because although it's convenient to define operators on other types (like complex numbers, vectors etc), there are always implementation-dependent idiosyncrasies. So operators don't always do what you expect them to do. By avoiding operator overloading, it's more transparent which function is called when. A wise design move in some people's eyes.