Marcus Deviln wrote:Your question is: "what does 42 + 44 + Foo() evaluate to?... I thought I laid that out for you guy: "86foo" I will try to explain clearer if I can. In the output the integers are being combined in spite of the fact that the method they are being combined with returns a string. That is what is throwing me off. I had an impression of the rules whereby: In the event of a string combined with an integer you would concatenate. If you have two integers only then you will combine the two. If Foo() returns a string then shouldn't we be concatenating only in the output and not combining?
I didn't see that in your original post. You talked about Foo() +42 + 44. I figured it was order of operation.
anyways, for me...
System.out.println( "x" + 1 +2 ); displays x12 and
System.out.println( 1 + 2 + "x" ); displays 3x
so it's left to right, and it's not clear to me why your Foo() + 42 +44 doesn't return foo4244. good luck with it
your 42 + 44 + Foo() looks right though, but again, that wasn't part of your original post.