- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Why is operator overloading not supported by java?
85 Lectures 6 hours
When a class has two or more methods by the same name but different parameters, at the time of calling based on the parameters passed respective method is called (or respective method body will be bonded with the calling line dynamically). This mechanism is known as method overloading.
Operator overloading is the ability to redefine the functionality of the operators. Programming languages like c++ supports operator overloading.
you can redefine or overload most of the built-in operators available in C++. Thus, a programmer can use operators with user-defined types as well.
Overloaded operators are functions with special names: the keyword "operator" followed by the symbol for the operator being defined. Like any other function, an overloaded operator has a return type and a parameter list.
Java does not support operator overloading due to the following reasons −
- Makes code complex − In 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 Integrated development environment 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.
- Why multiple inheritance is not supported by Java?
- Why multiple inheritance is not supported in Java
- Why is method overloading not possible by changing the return type of the method only in java?
- What is overloading a unary operator in C++?
- Overloading unary operator in C++?
- What is Overloading in Java?
- Rules for operator overloading in C++
- Overloading array index operator  in C++
- What is constructor overloading in Java?
- What is method overloading in Java?
- How to implement operator overloading in C#?
- How to use Operator Overloading in C#?
- Increment ++ and Decrement -- Operator Overloading in C++