• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on Operator Overloading  RSS feed

 
sudharsan reddy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

Why java doesnot support operator overloading.

Thanks in Advance.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there!

From a response at JGuru:

Actually, it does support operator overloading... of a very limited, built-in only nature. For instance "+" is overloaded for String's in addition to the usual arithmetic.

Of course, most people want to know why Java does not support user-defined operator overloading. :-) The simplest answer seems to be that the Java creators did not, at the time, see any clean way to add it to the language without making Java a mess (like C++) in the process.

Anyone else have any in depth knowledge of the decision for this?
 
Bablu Gope
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because of ambiguity , java operator overloading concept is not using in java except String concatenation(+).
 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look in your other thread, you will find that there are other overloaded operators. More details (though probably difficult to read) in the Java® Language Specification. Actually, the newer editions of the JLS don't use the term overloading.

And welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!