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, 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.
Joined: Oct 13, 2005
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.