I am trying to understand how the compiler views the following print statements. It is simple yet a bit intriguing.
This prints the added value. Convincing enough.<
I guess the Java specification explains it best:
The + operator is syntactically left-associative, no matter whether it is determined by type analysis to represent string concatenation or numeric addition. In some cases care is required to get the desired result. For example, the expression:
a + b + cis always regarded as meaning:
(a + b) + c
So, if a was a String, then it concatenates with b. The result would be of String type, hence it continues to concatenate with c.