does java support operator overloading

0 votes
I don't know the reason why java does not support operator overloading? can anyone help?
Jun 18, 2018 in Java by scarlett
• 1,290 points
20,968 views

1 answer to this question.

0 votes

Java doesn't supports operator overloading because it's just a choice made by its creators who wanted to keep the language more simple. Every operator has a good meaning with its arithmetic operation it performs. Operator overloading allows you to do something extra than what for it 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. To learn more about Java supports, you should join our Java certification class now.

answered Jun 18, 2018 by Akrati
• 960 points
Lies, Java has operator overloading for Strings.  They just don’t let you do it because the creators feel programmers are too stupid.

Hey, @Freebird,

Java does not support operator overloading due to the following reasons −

  • Makes code complex − In the case of operator overloading the compiler and interpreter (JVM) in Java need to put an extra effort to know the actual functionality of the operator used in a statement.
  • Programming error − Custom definition for the operators creates confusion for the programmers especially the new developers. Moreover, while working with programming languages that support operator overloading the program error rate is high compared to others.
  • Easy to develop tools like IDEs − Removal of operator overloading concept keeps the language simple for handling and process leading to a number of the Integrated development environments in Java.
  • Method overloading − The functionality of operator overloading can be achieved in Java using method overloading in Java in a simple, error-free and clear manner.

Related Questions In Java

0 votes
3 answers

Does Java support Default Parameters?

You can try this with method overloading. void ...READ MORE

answered Sep 21, 2018 in Java by Sushmita
• 6,900 points
5,447 views
+1 vote
1 answer

concat() vs “+” operator : In Java for String concatenation

Basically, there are two important differences between ...READ MORE

answered Apr 27, 2018 in Java by Rishabh
• 3,620 points
2,966 views
0 votes
2 answers

Does the finally block always execute in Java?

public static void main(String[] args) { ...READ MORE

answered Aug 8, 2018 in Java by Sushmita
• 6,900 points
995 views
0 votes
1 answer

What does Java option -Xmx stand for?

-Xmxn: It specifies the maximum size, in bytes, ...READ MORE

answered May 9, 2018 in Java by sharth
• 3,350 points
744 views
+5 votes
4 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,450 points

edited Nov 7, 2018 by Omkar 51,340 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,500 points
6,068 views
0 votes
1 answer

What are the differences between getText() and getAttribute() functions in Selenium WebDriver?

See, both are used to retrieve something ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,500 points
13,249 views
0 votes
1 answer

Selenium JARS(Java) missing from downloadable link

Nothing to worry about here. In the ...READ MORE

answered Apr 5, 2018 in Selenium by nsv999
• 5,500 points
2,595 views
0 votes
1 answer

What does NaN mean in Java?

"NaN" stands for "not a number". "Nan" ...READ MORE

answered Jul 12, 2018 in Java by Akrati
• 960 points
605 views
0 votes
1 answer

Can quotes be added in a java string.how?

In Java, you can escape quotes with \: String ...READ MORE

answered Jun 14, 2018 in Java by Akrati
• 960 points
156 views