posted 22 years ago
Hi pohying hip,
As you know,expressions in java are evaluated from left to right,therefore the above output occurs.Lets examine it case by case:
In this case,first 1+2 is evaluated,which is equal to 3,then since the next argument is a string "3",therefore the previous 3 is converted to a string and joined to the String "3",which gives the output 33.
First "1"+2 is evaluated,which gives "12".Then "12"+3 is evaluated,which gives,123.
I hope that helps
Gautam