From the language specification:
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.
This means that b+=a
is equivalent to (byte)(a+b)
, instead of simply a+b
. The latter still needs a cast to byte
.