answersLogoWhite

0


Best Answer

Maybe because Sun said so. We have to bear with so many other idiosyncrasies too. But I guess that comes with every language.

There were two major reasons why operator overloading wasn't allowed in Java: "cleanliness" and compiler complexity. The main reason was the first, a personal preference choice made by Java's creator, James Gosling.

Operator overloading, while useful, can be exceedingly confusing, much more so than method overloading. Given the human tendency to assign specific meanings to single symbols, it is hard to get programmers to wrap their heads around multiple meanings for operators. What this means is that there is a marked increase in programming errors when a language supports operator overloading. Since practically the same benefit can be obtained via methods, the Java designers decided that the increased programmer mistake rate was not worth supporting operator overloading.

From a Java compiler (e.g. javac) design standpoint, supporting operator overloading is considerably more difficult than method overloading, requiring a more complex compiler.

User Avatar

Wiki User

โˆ™ 2012-03-04 05:13:11
This answer is:
User Avatar
Study guides

rtf

โžก๏ธ
See all cards
4.0
โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…
51 Reviews

Add your answer:

Earn +20 pts
Q: Why java not support operator overloading?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is an operator overloading in java?

Operator overloading refers to redefining what the mathematical operators (+-*/) do when applied to different objects. Java does not support operator overloading.


What are factors to be considered while overloading the operators?

Java does not support operator Overloading.


Why operator overloading not possible in Java?

Java does not support operator overloading because Sun deliberately omitted it, citing simplicity as the reason for omission.


Operator overloading is possible in java or not?

Operator overloading is not possible in Java.


What is overloaded operator?

Java does not support operator overloading. Operator overloading is the scenario where you overload a particular operator to do something that it is not designed to do. Ex: if you make the operator "*" do addition or the operator "-" do multiplication, imagine the chaos that would ensue in your program. So the java designers blocked this feature of operator overloading.


How do you overload operator?

Java does not support operator overloading. Operator overloading is the scenario where you overload a particular operator to do something that it is not designed to do. Ex: if you make the operator "*" do addition or the operator "-" do multiplication, imagine the chaos that would ensue in your program. So the java designers blocked this feature of operator overloading.


Why operator overloading is not there in java?

== == === === === === === === Some Body told me that operator overloading is not there because it violates the transparency of java.since there is no hiding of information in java it does support op overloading === === === === === === Pranab Kumar Rana Software Engineer..... === === === ===


Why operators not overloaded?

Java does not support operator overloading. Operator overloading is the scenario where you overload a particular operator to do something that it is not designed to do. Ex: if you make the operator "*" do addition or the operator "-" do multiplication, imagine the chaos that would ensue in your program. So the java designers blocked this feature of operator overloading.


What are the restriction that are applied to operator overloading?

Java does not support user defined operator overloading.The operator '+' is overloaded in Java and can be used for adding both numbers and Strings.


What is a operator overriding in java?

Java does not support object overriding. It does support operator overloading by means of the "+" symbol which is used for both numeric addition as well as string concatenation.


Why opreator overloading is not included in Java Programming Language?

Operator overloading was a feature of C++ that the Java language designers thought was too complicated and not useful enough to include.


C coding for operator overloading?

C does not support operator overloading. If you mean C++ operator overloading, it depends on exactly what you wanted to do. If you wanted to '+' to strings, then you could write: string operator+(string a, string b) { // do something }

People also asked