Consider the following:
int a = 1;
double b = 0.5;
System.out.println(a += b); // case x
System.out.println(a = a + b); // case y
What is immediately apparent is that the above does not even compile - case y will fail due to "incompatible types". If I run case x by itself, it will simply return a.
What is going on here? Does the shorthand operator (+=) "catch" the failed assignment and default to simply returning the lhand value? If that is so, is it really correct to claim that the a += b is equivalent to a = a + b, as is very common in tutorials?