It is a winning approach for business-ready applications. Well, now going to your question Operator overloading is a matter that concerns also multiple inheritance and other advanced characteristics of low level languages. Java, as well as C , Python and so on, is a managed language, made to be easy to write and useful for building complex applications in very few time.
If we included operator overloading in Java, the language would become more complex and difficult to handle. Introducing operator overloading is to be done carefully. What the hell are you telling me? Well, this is the answer. But this is not a good answer to the earlier question The real answer is that C is more complex than Java. This is a pro but also a con. It is a matter of deciding where to place the language: high level, higher level, very high level?
Well, Java does not support op overloading because it wants to be fast and easy to manage and use. When introducing op overloading, a language must also carry a large amount of problems caused by this new functionality. It is exactly like questioning: "Why does Java not support multiple inheritance?
Think about it No common class tree, no object class as a common base class for all classes, no possibility of upcasting safely and many problems to handle, manage, foresee, keep in count Java wants to be simple. Many others, here, also told you that overloading is useless.
Well I belong to those ones who think this is not true. Well, if you think this way op overloading is useless , then also many other features of managed languages are useless too. Think about interfaces, classes and so on, you really do not need them. You can use abstract classes for interface implementations Let's look at c Well, in managed languages everything that fasten a development process is welcome and does not imply uselessness.
The added value of managed languages is to be measured right on this elements. Op overloading is a very useful feature, it could be implemented in languages like Java, and this would change the language structure and purposes, it would be a good thing but a bad thing too, just a matter of tastes.
But today, Java is simpler than C even for this reason, because Java does not supports op overloading. Java doesn't support operator overloading one reference is the Wikipedia Operator Overloading page. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Why doesn't Java need Operator Overloading?
Asked 11 years, 2 months ago. Active 5 years ago. Viewed 31k times. Improve this question. Rob Hruska k 28 28 gold badges silver badges bronze badges. Just because it doesn't have a feature doesn't mean it doesn't need it.
Java is a simple relatively language. Operator overloading is probably one of the most complex features of the languages that allow it except maybe multiple inheritance — Falmarri. In the CLR operator overloading is just syntatic sugar for calling a static method e.
See also stackoverflow. Falmarri Java contains much more complex features than operator overloading inner classes, autoboxing, generics. In fact, if it weren't for autoboxing, operator overloading could be added in a completely backwards compatible manner.
Antimony: Please explain how autoboxing is the only thing preventing operator overloading. Show 2 more comments. Active Oldest Votes. Improve this answer. Gonen I 4, 21 21 silver badges 47 47 bronze badges. Sanjay Manohar Sanjay Manohar 6, 3 3 gold badges 33 33 silver badges 54 54 bronze badges. That is almost true, since it defines addition on char and string types. Difference between static and nonstatic methods java Why Java does not support pointers? What is package in Java? What are wrapper classes?
What is singleton class in Java? Can a top level class be private or protected in java Are Polymorphism , Overloading and Overriding similar concepts? Why can't a Java class be declared as static? How to generate random integers within a specific range in Java What's the meaning of System. What is the purpose of Runtime and System class? What is finally block in Java? What is difference between final, finally and finalize?
What is try-with-resources in java? What is a stacktrace? What is the meaning of immutable in terms of String? What are different ways to create a string object in Java? How do I convert String to Date object in Java? How do I create a Java string from the contents of a file? You can use Java Runtime. First, find an XPath which will return See, both are used to retrieve something Nothing to worry about here.
In the Already have an account? Sign in. Home Community Categories Java does java support operator overloading. I don't know the reason why java does not support operator overloading? Your comment on this question: Your name to display optional : Email me at this address if a comment is added after mine: Email me if a comment is added after mine Privacy: Your email address will only be used for sending these notifications. Your answer Your name to display optional : Email me at this address if my answer is selected or commented on: Email me if my answer is selected or commented on Privacy: Your email address will only be used for sending these notifications.
Lies, Java has operator overloading for Strings. Moreover, while working with programming languages that support operator overloading the program error rate is high compared to others. Your comment on this answer: Your name to display optional : Email me at this address if a comment is added after mine: Email me if a comment is added after mine Privacy: Your email address will only be used for sending these notifications.
0コメント