I've had such problem here using Java 1.5.0_06. I made lots of tests and came to some conclusions.
Please, correct me if I am wrong because that is important to all of us.
Any combination of <primitive += primitive> or <primitive += wrapper> can be made because the += operator implicitly casts the result of the operation to left side primitive type. Here are some strange examples:
Double D = 1.0;
Character C = 1;
byte b = 1;
b += C; // OK
b += D; // OK
Using wrappers on the left side of += operator (like <wrapper += wrapper> or <wrapper += primitive>
, it seems to work like an ordinary addition operation, where its result will be cast implicitly to int, long, float or double, depending on the primitives involved on the operation (at least one of them is an unboxed wrapper). Then, some combinations are not allowed, like
Integer I = 1;
Double D = 1.0;
float f = 1.0f;
I += D; // Compiler fails � the result is a double
I += f; // Compiler fails � the result is a float
(But that is valid with primitive on the left side of += operator, that�s it, if variable 'I' were an int instead of an Integer wrapper.)
Maybe that explains why Byte, Short and Character wrappers do not work with += operator, since they can not get assigned to any of those primitives without explicit cast (narrowing).