Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Operator Overloading in java ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Operator Overloading in java ?" Watch "Operator Overloading in java ?" New topic
Author

Operator Overloading in java ?

vijin das
Ranch Hand

Joined: Jun 07, 2010
Posts: 129

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 ....

VIJINDAS
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
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

Joined: Jun 07, 2010
Posts: 129

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

yes then shall i confirm that ....
Avishkar Nikale
Ranch Hand

Joined: Aug 06, 2010
Posts: 173
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).




Regards,
Avishkar Nikale
vijin das
Ranch Hand

Joined: Jun 07, 2010
Posts: 129

Avishkar Nikale wrote:.
Thanks for sharing info Avishkar
Vinoth Kumar Kannan
Ranch Hand

Joined: Aug 19, 2009
Posts: 276

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.


OCPJP 6
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38007
    
  22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Operator Overloading in java ?
 
Similar Threads
operator ==
interview question
Operator Overloading in JAVA
operator overloading..
Re: Operator Overloading