Why operator overloading is not allowed in Java?

Showing Answers 1 - 6 of 6 Answers

K.V.N.R.MURALI KRISHNA

  • Mar 29th, 2006
 

By using the operator overload have lot of problems is there. even some time the programmer get coufused. and its increase the complexity of the program. for that purpose only its removed in java.

  Was this answer useful?  Yes

muthukrishnan

  • Apr 7th, 2006
 

to avoid memmory usage in more than one time

  Was this answer useful?  Yes

Rajasekar.N

  • Apr 7th, 2006
 

operator overloading will increase the complexity of the program.. to minimize the complexity java doesnt allow operator overloading.

But java is object oriented... for that only reason java support one operator overloading.. "+"..

                this "+" used to concat and to add two numbers

E.G int c = a+b; here the + operator is used to add two variable
    

      System.out.println(" the value of c "+c); concat string and int

  Was this answer useful?  Yes

Shibaji Paul

  • Apr 19th, 2006
 

Operator overloading may change the universally standard meaning of operators. For example we may overload "+" operator for a particular object which in practice may subtract the values, which definitely leads into a serious misconception.

  Was this answer useful?  Yes

Shibaji Paul

  • Apr 19th, 2006
 

Operator overloading may change the universally standard meaning of operators. For example we may overload "+" operator for a particular object which in practice may subtract the values, which definitely leads into a serious misconception.Exp class Complex { private : int real, img; public: Complex(int real, int img) { this->real = real; this->img = img; } void printComplex() { cout<<"\n"<real - z.real; temp.img = this->img - z.img; } } In the above example, we have overloaded the "+" operator for the Complex class, in practice the overloaded "+" operator in subtracting 2 complex numbers. This kind of coding, if done, would definitly lead to serious consequences.

  Was this answer useful?  Yes

Java is a platform independent language, whereas operators are platform-dependent. Each operating system has its own behavior for the operators. If we have overloaded an operator for one operating system and run the program in some other operating system , then it may raise conflicts with the original behavior of the operator in that operating system.

For instance, ?$? has no significance in ?windows? whereas in ?Linux/Unix? it can be used in shellscripts and environmental variables.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions