3.1-Understanding Java Operators Flashcards
What is a Java operator?
A Java operator is a special symbol that applies an operation to a set of values, literals, or variables, —referred to as operands—and returns a result.
What is an operand?
The term operand, refers to the value, literal or variable an operation is applied to via an operator
What is call the output of the operation?
It’s simply referred to as the result.
Are Java operators evaluated from left-to-right order?
Not necessarily, they follow the pre-defined Order of operator precedence.
What is Operator Precedence?
Determines what order operators should be evaluated.
What can alter the Operator precedence?
parentheses
🤯️⚠️📣️ What are the Operators precedence?
0°Parentheses: ()- 1° Unary: (***Post), Pre, ~, !, +, - 2° Arithmetic: *, /, %, +, - (***Numeric Promotion) 3° ShiftBitwise: >>, <>> 4° Relational: , >=, (***instanceof) 5° Comparisson: ==, != 6° Logical(Bitwise and Short-circuit): &, |, ^, &&, || 7° Ternary: ? : 8° Assignment: =, +=, -=, *=, /= -> ⚠️Internal Type casting -> ⚠️Unperformed Side Effects -> ⚠️Composed Assignment ❌(Inline-declaration)
How to change the operation precedence?
By wrapping parentheses around the sections we want
to be evaluated first.
⚠️📣️ Make sure they are always valid and balanced.
✅Only parentheses ( ) ❌ [ ], < >, \ /, { }