1. Assignment operator =
Variable name = expression;
Assigns the value of the expression to the right of the equal sign to the variable to the left of the equals sign
2. Arithmetic operator +-*/% + +--
+ + Add and re-operate before the first
+ + at the back of the first operation in the self-added
Compound assignment operator
+= -= *= /= %=
sum+=5; equal to sum=sum+5;
3. Relational operators (comparison operators)
> < >= <= = = =!
The relational operator must finally derive a Boolean value (True,false)
4. Logical operators
&& (and) the expression is all true, the result is true, and the reverse is false
If there is an expression of false, the result is false, short-circuiting immediately, no subsequent expressions are executed
& (no short circuit)
|| The (or) expression has a true, the result is true, and the inverse is false
If there is an expression of true, the result is true, short-circuiting immediately, without executing the subsequent expression
| (no short circuit)
The (inverse) expression is true, reverse is false
5. Three mesh operator
(conditions)? Expression 1: Expression 2
When the condition is true, run expression 1, false when you run expression 2.
6. Operator Precedence
Highest priority: ()
Lowest Priority: =
Priority level:! > Arithmetic operators > Relational operators > && > | |
Jen Baby Java basic notes operator