What are order of precedence and associativity how are they used ?
Answer : Please have below operators and list are in according to its precedence order and some points:
- Table top starts from highest precedence.
- Those operators who has higher precedence will be evaluated before compare to operators with lower precedence
- When operators are on same line they will have equal precedence
- If operators of equal precedence appears in same expression then a rule will govern which will be evaluated first
- All binary operators except for the assignment operators will be evaluated from left to right
- Assignment operators will be evaluated from right to left
|unary||++expr –expr +expr -expr ~ !|
|multiplicative||* / %|
|shift||<< >> >>>|
|relational||< > <= >= instanceof|
|bitwise exclusive OR||^|
|bitwise inclusive OR||||
|assignment||= += -= *= /= %= &= ^= |= <<= >>= >>>=|