does java support operator overloading?

Java

I don't know the reason why java does not support operator overloading? can anyone help?


If you want to unleash your potential in this competitive field, please visit the Java course page for more information, where you can find the Java tutorials and Java frequently asked interview questions and answers as well.

2
Answers

Replies

Java does not support operator overloading because it’s just a choice made by the creators  who want to keep the language more simple. Operator overloading allows you to do something extra than what is expected for. Java only allows arithmetic operations on elementary numeric types. If you allow a developer to do operator overloading they will come up with multiple meanings for the same operator which will make the learning curve of any developer hard and things more confusing and messy. The Java designers wanted to prevent people from using operators in a confusing manner, but it was not worth it. By avoiding operator overloading, it's more transparent which function is called when.Avoiding operator overloading in Java made the implementation and specification of Java a little simpler.

 


No, java does not support operator overloading. As we all know that there is no specific reason defined but yes, we can clarify in a few points.



What happens if java supports operator overloading=>



Increases Code Complexity: As we all know that every operator has its unique meaning and functionality. So if we perform operator overloading then the overloaded operator come up with multiple meaning and functionality so it is difficult and complex for the JVM(Java Virtual Machine) to find out the standard functionality of the operator if it used in an expressions then JVM will have to do more efforts and time to achieve the actual functionality of the operator.



Increases Programming Errors: As, we all know that if we perform operator overloading then the same operator may have multiple functionality so if we use the overloaded operator in a single java program then the programmer gets confused and messed the things whether this operator is being used to perform this task or that task.



Reduces Simplicity Of The Application: As, we all know that if we perform operator overloading then Java creators allow developers to create complex code and implementations that will be time taking and expensive to understand so it is not as much as cost effective, and simpler as we expect.


 

 
 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
WhatsApp
To Top