Compound assignment operators (+=, *= etc) have strange ways so ready this carefully: 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
The expression is a constant expression of type int. The type of the variable is byte, short or char. The value of expression is representable in the type of the variable. NOTE THAT narrowing conversion doesn't apply to long or double. So, char ch = 30L; will fail althrough 30 is representable by a char.
|