Operators | Precedence |
---|---|
postfix | expr++ expr-- |
unary | ++expr --expr +expr -expr ~ ! |
multiplicative | * / % |
additive | + - |
shift | << >> >>> |
relational | < > <= >= instanceof |
equality | == != |
bitwise AND | & |
bitwise exclusive OR | ^ |
bitwise inclusive OR | | |
logical AND | && |
logical OR | || |
ternary | ? : |
assignment | = += -= *= /= %= &= ^= |= <<= >>= >>>= |
'+' - this is used for concatenation of 2 strings.
int result = 1;
result--;// this means result = result-1; but after any operation done with result--
1-(result--) = 0;// the new result value is 0 but after the operation hence end result of the expression is 0
1 -(--result) = 1;// the new result value is 0 but before the operation hence end result of the expression is 1
check - http://download.oracle.com/javase/tutorial/java/nutsandbolts/op1.html for more clarity.
No comments:
Post a Comment