Difference between revisions of "Operators"
From Suhrid.net Wiki
Jump to navigationJump to search (→Intro) |
|||
Line 3: | Line 3: | ||
* +=, -=, *= and /= | * +=, -=, *= and /= | ||
* Makes code compact | * Makes code compact | ||
+ | * Operator precedence for compound assignments : The expression on the right side of the = will always be evaluated first! | ||
+ | |||
+ | <syntaxhighlight lang="java5"> | ||
+ | |||
+ | int x = 2; | ||
+ | |||
+ | x *= 3 + 5; | ||
+ | |||
+ | //This is equivalent to x = x * (3 + 5) and NOT x = (x*2) + 5. | ||
+ | |||
+ | </syntaxhighlight> | ||
Revision as of 03:11, 31 August 2011
Compound Operators
- +=, -=, *= and /=
- Makes code compact
- Operator precedence for compound assignments : The expression on the right side of the = will always be evaluated first!
int x = 2;
x *= 3 + 5;
//This is equivalent to x = x * (3 + 5) and NOT x = (x*2) + 5.