Possible Duplicate:
What is the difference between += and =+?
Apparently =+
is a valid operator. Where would you use it?
Example:
int j, k = 0;
j =+ k;
Possible Duplicate:
What is the difference between += and =+?
Apparently =+
is a valid operator. Where would you use it?
Example:
int j, k = 0;
j =+ k;
This is not a comparison operator, it is simple assignment. You are just adding a sign to your variable. If you added a -
, it would negate it.
Also another important aspect of the combined operators like =+ or =- is the fact they add an implicit cast. This is vital when you are doing operations on bytes (for example). \
byte a = 1;
byte b = 2;
a += b; //this is valid add operation
Note: the sum of two bytes is an int value, unless you do a cast.
a =(byte) a + b //but with the compound assignment you dont have to include the cast.