Why does JAVA not support user define operator overloading? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

Why does JAVA not support user define operator overloading?

The other languages like c++ supports operator overloading and it is the good thing. Operator overloading provides us to use a operator for different types of uses and overloading shows the polymorphic behavior of operators. When we overload an operator then with this operator we can perform directly operation on objects and it is beneficial for a programmer. So, why does Java not provide the facility to overload operator?

20th Mar 2017, 7:38 PM
NEERAJ CHOUHAN
NEERAJ CHOUHAN - avatar
17 Answers
+ 17
I don't know the truth but write down my opinion. If a language supports operator overloading then it is easy to write program which can be understood very hard. You have to know how a class overrides different operators to understand what a code does. You can override + to work as - for example. In Java it is important to be able to write safe and easily understandable code fast. And operator overloading breaks this goal and isn't needed at all.
20th Mar 2017, 7:56 PM
Tamás Barta
Tamás Barta - avatar
+ 10
It is not really needed. Java usually implements core features with high impact, features like this only to be fancy and shiny is not really valuable for java, while you define a method instead of operator overload, and there you have the same. This is how I see they are thinking, no properties and fancy stuff, functionality comes first.
21st Mar 2017, 10:36 AM
Magyar Dávid
Magyar Dávid - avatar
+ 9
We can't say here it is good or not. Operator overloading (as other functionalities​ too) has pros and cons. It has​ to be decided if it is worth to implement. I think it is very subjective what is important for you: simplicity, performance, safe coding, readable codes or others? It is like religion. I have been working in Java + C++ teams for 15 years about, so my opinion is Java choose the more effective way: much faster and safer development -> lower project cost and much less bugs
23rd Mar 2017, 5:51 AM
Tamás Barta
Tamás Barta - avatar
+ 4
Because java is a simple language that does not include ambiguous stuffs like operator overloading , multiple inheritance, Etc. Moreover, java lacks all complex operations that are supported in other languages. That's why JAVA is very famous. Famous for it's simplicity.
21st Mar 2017, 8:50 PM
Nikhil Kumar
Nikhil Kumar - avatar
23rd Mar 2017, 2:14 AM
Rudrapratap Singh
Rudrapratap Singh - avatar
+ 3
Java Creator James Gosling goes by the philosophy: "When you move to a new apartment, don't unpack. Just sort of move in, and as you need things, pull them out of the boxes. After you've been in the apartment for a couple of months, take the boxes -- don't even open them -- and just leave what's in there and throw them out."
24th Mar 2017, 12:04 AM
Logan New
Logan New - avatar
+ 1
It does support in some cases, if u are an experienced programmer u will have come across it many times
22nd Mar 2017, 11:02 AM
Vishal Wadkar
Vishal Wadkar - avatar
+ 1
Because while developing Java the complex functions of c/c++ were removed like pointers n operator overloading in JVM
22nd Mar 2017, 4:06 PM
vicksheet shanbhag
+ 1
I think , java does not support pointers which is the main reason ,why java doesn't have operator overloading
27th Mar 2017, 6:12 AM
Kuldeep Randhawa
Kuldeep Randhawa - avatar
0
In simple speak, C++ trusts the programmer and assumes they know what they're doing. Java does not trust the programmer, and keeps them from doing certain things.
23rd Mar 2017, 4:22 AM
Luke Wilson
Luke Wilson - avatar
- 1
انا مبتدئة اريد ان اتعلم ارجوكم
23rd Mar 2017, 9:07 PM
sami
- 1
Because it is a computer laungage
26th Mar 2017, 7:25 AM
Kamna Singh
Kamna Singh - avatar
- 1
no this overloading
26th Mar 2017, 1:22 PM
Youssef.Wael
- 1
ووس
26th Mar 2017, 1:23 PM
Youssef.Wael
- 2
I think so java don't allow users to do certain things as it do not trust them
23rd Mar 2017, 4:14 PM
Tilak Tiwari
- 5
I'm try to use this app.
24th Mar 2017, 3:26 AM
Firdaus Abdullah
- 7
ووس
22nd Mar 2017, 10:02 PM
jgauh