• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

About Operator Overloading...

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

why doesn't java support operator overloading...?

i need the clear idea about this please anyone
explain this in detail...


Thank you

regards,
Vijay
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's some info:

Bug ID: 4905919 RFE: Operator overloading
Operator Overloading Considered Harmful
The Java Language Environment - Features Removed from C and C++

The bottom line is that the people who invented Java thought that operator overloading makes code too complicated and isn't really necessary.

Use Google to find more info.
 
Marshal
Posts: 80230
424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not quite true that Java doesn't support operator overloading; the "+" operator is overloaded so it acts as addition most of the time, but in the case of Strings represents concatenation.

You can use | for "logical OR" with two boolean expressions and for "bitwise OR" with two integer numbers, similarly with & and ^, but you might not call that overloading.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's right, some operators are overloaded such as "+" for strings, but these are special cases - the compiler handles them specially.

Java does not have user-defined operator overloading; you cannot overload operators yourself.
 
vijay Krishnan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah i know that eventhough i need some clarifications about this that is why i posting this question.

thank you guys for explaing this concept to me.
thank you so much.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic