Until today, I thought that for example:
i += j;
Was just a shortcut for:
i = i + j;
But if we try this:<
Very good question. The Java Language specification confirms your suggestion.
For example, the following code is correct: short x = 3; x += 4.6; and results in x having the value 7 because it is equivalent to: short x = 3; x = (short)(x + 4.6);
For example, the following code is correct:
short x = 3; x += 4.6;
and results in x having the value 7 because it is equivalent to:
short x = 3; x = (short)(x + 4.6);