• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

Operator Overloading in java ?

 
Ranch Hand
Posts: 129
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know java language does not provide operator overloading facility for developers ...

But whether java language internally using operator overloading facility (such as String concatination using + operator )??

Any one have idea ....
 
Marshal
Posts: 74342
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If String catenation with the + operator isn't operator overloading, what is it?

Other overloaded operators are & | ^. Some people say ++ and -- are overloaded, too. Search for operator/operators overloading/overload/overloaded; this question is asked regularly.
 
vijin das
Ranch Hand
Posts: 129
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:If String catenation with the + operator isn't operator overloading, what is it?

yes then shall i confirm that ....

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vijin,

Operator overloading makes easy to read code
but can be replaced with methods/functions which do the same thing.

So I should say "nice to have" but not needed.

So "+" overloading for String is given by Java at compile time
but who knows the byte code might still call the concat() method if one these is a reference
& make a bigger literal if both are literals.

Since String will require concatenation the most of all Objects which can be created in
a program "+" has a better readability & can be used.

But for custom or any other objects, nope there isn't any (till now).



 
vijin das
Ranch Hand
Posts: 129
Firefox Browser Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Avishkar Nikale wrote:.
Thanks for sharing info Avishkar

 
Ranch Hand
Posts: 276
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vijin, it would be much better/understandable if you write your comments outside the 'quote' block.
'quote' blocks are just to indicate - to which part of the previous post(s) you are commenting to. If your comments are inside some 'quote' block , then people reading the posts may possibly get confused.
If you have nothing to quote at all, a better option is clicking 'Post Reply' button at the bottom.
 
Campbell Ritchie
Marshal
Posts: 74342
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Avishkar Nikale wrote:. . . Operator overloading makes easy to read code . . .

Does it really? I am writing a parser which has to distinguish - in 1 - 2 from - in -123 from - in 1.23e-45. I am not at all convinced that lots of overloaded operators make your code easy to read.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic