[95] in java-interest
Re: Overloading of "+" for string concat
daemon@ATHENA.MIT.EDU (Jeremy Fitzhardinge)
Thu May 18 14:30:20 1995
From: jeremy@sour.sw.oz.au (Jeremy Fitzhardinge)
Date: Thu, 18 May 1995 16:36:14 +1000 (EST)
To: java-interest@java.Eng.Sun.COM
> b) The expression "a + b + c" means the same thing as "a + (b + c)" in
> the more common case of addition. The fact that it doesn't in string
> concat involving implicit invocation of toString() is non-intuitive.
No, addition works the same whether the types are Strings or not.
That is, it groups "(a + b) + c", which is exactly the behaviour
you were seeing. This is how addition is defined in ISO C (6.3.6,
Additive operators), and therefore how it's defined in Java.
> (You weren't really proposing that I parenthesize an expression like
> "a + b + c" were you ?)
When you're relying on implicit type conversions in an expression,
you do have to parenthesize to get the right effect.
J
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com