Unlike C++, Java doesn't back upward operator overloading. Java doesn't supply liberty to programmer, to overload the touchstone arithmetics operators e.g. +, -, * as well as / etc. If y'all possess got worked previously inwards C++, than y'all know that, Java has left lot of characteristic supported inwards C++ e.g. Java doesn't back upward multiple inheritance, no pointers inwards Java, as well as no move past times past reference inwards Java. Rarely this inquiry asked inwards Java interviews, to banking enterprise lucifer how programmer thinks close certainly features, which is non supported inwards Java. Another similar questions is regarding Java existence move past times past reference, which is to a greater extent than oft than non look as, whether Java is move past times past value or reference. Though I don't know the existent argue behind it, I retrieve next observation brand feel on, why Operator overloading is non supported inwards Java.
1) Simplicity as well as Cleanliness
object oriented language. Adding Operator overloading would possess got definitely made pattern to a greater extent than complex than without it, as well as it mightiness possess got atomic number 82 to to a greater extent than complex compiler or slows the JVM ,because it needs to exercise extra operate to set the actual pregnant of operators, as well as trim down the chance to optimize the linguistic communication past times guarantee conduct of operators inwards Java.
2) Avoid Programming Errors
Java doesn't allow user defined operator overloading, because if y'all allow programmer to exercise operator overloading, they volition come upward up amongst multiple meanings for same operator, which volition brand the learning bend of whatsoever developer hard as well as things to a greater extent than confusing as well as messy. Its been observed that, at that spot is increase inwards programming errors, when linguistic communication supports operator overloading, which inwards plow increase e evolution as well as delivery time. Since Java as well as JVM has taken most of developers responsibility, inwards retention administration past times providing garbage collector, it doesn't actually brand feel to left this characteristic to pollute the code, as well as equally a loop hole for programming errors.
3) JVM Complexity
From JVM perspective, supporting operator overloading is to a greater extent than difficult, as well as if the same affair tin move achieved, past times using method overloading inwards to a greater extent than intuitive as well as build clean way, it does brand feel to non back upward operator overloading inwards Java. Influenza A virus subtype H5N1 complex JVM, may consequence inwards slower JVM, than a relatively simpler JVM ,and trim down the chance of optimization past times taking out guaranteed conduct of operators inwards Java.
4) Easy Development of Tools
This is an additional exercise goodness of non supporting operator overloading inwards Java. Omission of operator overloading has kept the linguistic communication easier to guide maintain as well as process, which inwards plow makes it easier to railroad train the tools, that procedure the linguistic communication e.g. IDE or re-factoring tool. Re-factoring tools inwards Java are far meliorate than C++.
Further Learning
Complete Java Masterclass
method overloading using to a greater extent than intuitive as well as like shooting fish in a barrel agency as well as that mightiness move the argue coffee designer idea that supporting operator overloading volition non move a big exercise goodness for language, only inwards fact exclusively Java designer tin answer existent motivation of, why Java doesn't back upward operator overloading, similar another questions equally Why Java doesn't back upward multiple inheritance or Why String is immutable inwards Java.