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
41,754 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,920 points
6,949 views
0 votes
1 answer

Does Java have a "IN" operator or function like SQL? [duplicate]

The Java language is designed to be ...READ MORE

answered Feb 2, 2022 in Java by Vaani
• 7,070 points

edited Jun 22, 2023 by Khan Sarfaraz 5,322 views
0 votes
1 answer

Why Java does not support multiple inheritance?

Java does not support multiple inheritance through ...READ MORE

answered Oct 23, 2023 in Java by anonymous
• 3,360 points
455 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
4,760 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 81,302 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
8,383 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
17,467 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

edited Aug 4, 2023 by Khan Sarfaraz 4,891 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
2,343 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
703 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP