Operators Flashcards
What do we need to watch out when using operators?
For usage of = in code
Which operators have the highest precedence?
Post-unary operators (expression++, expression–)
What comes after post-unary (expression++, expression–) operators in precedence?
Pre-unary operators (++expression, –expression)
What is the precedence order of other unary operators (-, !, ~, +, (type)) ?
Other unary operators come after pre-unary operators (++expression, –expression)
Where does the cast operator ((Type)reference) fit in the precedence order?
The cast operator has the same precedence as other unary operators (-, !, ~, +, (type))
What operators come after unary operators (-, !, ~, +, (type)) in precedence?
Multiplication/division/modulus operators (*, /, %)
What is the next level of precedence after multiplication/division/modulus? (*, /, %)
Addition/subtraction operators (+, -)
Where do shift operators («,»_space;,»_space;>) fall in the precedence order?
Shift operators («,»_space;,»_space;>) come after addition/subtraction (+, -)
What comes after shift operators («,»_space;,»_space;>) in precedence?
Relational operators (<, >, <=, >=, instanceof)
What is the precedence of equality operators compared to relational operators? (<, >, <=, >=, instanceof)
Equality operators (==, !=) have lower precedence than relational operators
In what order do the bitwise operators come?
After equality operators (==, !=) - Logical AND (&), then Logical XOR (^), then Logical OR (|)
Where do conditional AND (&&) and OR (||) fit in the precedence order?
Conditional AND (&&) has higher precedence than conditional OR (||), both come after bitwise operators
What is the precedence of the ternary operator?
The ternary operator (?:) comes after conditional OR and before assignment operators
Where do assignment operators (=, +=, -=, etc.) fall in the precedence order?
Assignment operators (=, +=, -=, etc.) have one of the lowest precedences
What operator has the lowest precedence?
The arrow operator (->) has the lowest precedence