pure.java pure.java - 1 year ago 89
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download