posted 24 years ago
Following is from the JLS. Hope this clarifies ur doubt.
A compound assignment expression of the form E1 op= E2 is equivalent to E1 = (T)((E1) op (E2)), where T is the type of
E1, except that E1 is evaluated only once. Note that the implied cast to type T may be either an identity conversion (�5.1.1) or
a narrowing primitive conversion (�5.1.3). 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);
Ankur