Operators in java 7
This tutorial describes the concept of operators in java 7.
Operators :
For doing different kind of manipulation we need operators. Java provides many operators. In general you can say operators are a special symbol that do specific operations on one or more operands and after manipulation returns some result.
You can divide operators in the following list -
- Arithmetic Operators
- Unary Operators
- Relational Operators
- Bitwise Operators
- Logical Operators
- Assignment Operators
- Misc Operators
Precedence Order of Java Operators -
When we apply more than one operators in our expression then expression executed according to the highest precedence operator. That means the operator run first according to the higher precedence order. All the expression is evaluated according to the precedence order of operators. The higher order performed first than the other and in the same way other operators are executed.
Operators | Precedence | Association |
postfix | expr++ expr-- | Left to right |
unary | ++expr --expr +expr -expr ~ ! | Right to left |
multiplicative | * / % | Left to right |
additive | + - | Left to right |
shift | << >> >>> | Left to right |
relational | < > <= >= instanceof | Left to right |
equality | == != | Left to right |
bitwise AND | & | Left to right |
bitwise exclusive OR | ^ | Left to right |
bitwise inclusive OR | | | Left to right |
logical AND | && | Left to right |
logical OR | || | Left to right |
ternary | ? : | Right to left |
assignment | = += -= *= /= %= &= ^= |= <<= >>= >>>= | Right to left |