I'm using netBeans 5.0 to run my programs, and now I'm realizing the disadvantage of using an IDE to learn...
When I tried the code below,
double i, x = 1; x += i; // Must be LEGAL x = x + i; // Must be ILLEGAL
My IDE showed error only in the first line...I mean I did not compile it and it showed me by underlining the first line in red that variable might not have been initialized but nothing was shown in the next line which confused me. After I commented the first line, I got it cleared.
Anyways, for the first question you posted, the explanation is compound assignment operators does not require an explicit cast but whereas normal operators would result in an int value for which an explicit cast to int is required. On the other hand if one of the variable is of type double, the resultant of the arithmetic operation is promoted to double.