Outline
3.5.1 Assignment operator
The assignment operator is: "=", which is a two-tuple operator (that is, two operands are processed), and its function is to assign the right operand to the left operand.
Format:
Variable type variable name = assigned value;
The left side must be a variable, and the right side can be any numeric or expression: include a variable (such as a number), a constant (123 book), an expression (45*12).
In Java, you can use the assignment operator serial together: x=y=z=6; Although yes, it is not recommended.
3.5.2 Arithmetic operator emphasis
In Java, arithmetic operators mainly have +-*/% (take-up).
where +-can also be used as a digital sign, such as +5,-7.
3.5.3 Self-increment decrement operator focus
The self-increment decrement operation is assigned the monocular operator, either before the operand or after the operand, and the operator must be an shaping or floating-point variable.
(1) ++a;==> indicates that a plus 1 is used before using the A variable.
That
int a=1;
int b=++a;
System.out.print (a); ==>2
System.out.print (b); ==>2
-the same as before the variable.
(2) a++;==> means assigning a value to a, plus 1.
That
int a=1;
int b=a++;
System.out.print (a); ==>1
System.out.print (b); ==>2
-the same as before the variable.
3.5.4 comparison Operators
The comparison operator is a two-tuple operator that is used for comparisons between a program's total variables and variables, between variables and constants, and between other information. The result of the comparison operator is a Boolean, and when the operator correspondence is established, the result of the operation is ture, otherwise the result is false.
3.5.5 logical operators
Logical operators include && (&) (logic and), | | (| ) (logical OR) and! (logical non), returns a Boolean Boolean expression, and the operand must also be a Boolean data. Compared to a comparison operator, a logical character can represent more complex conditions, such as connecting several relational expressions. In the logical operator, except! is the hospital operator, and everything else is a two-dollar operator.
Operators meaning usage Combination Method results
&&/& Logic and Op1&&op2 left to right one wrong all wrong
|| / | Logic or op1| | Op2 left to right pair full pair
! Logical non-!op right to left opposite
The difference between && and &:
&& can omit the number of computer operations, play a "short-circuit" effect,&& so also known as "short-circuit operator";& also known as "non-short-circuit operator", it is recommended to use &&.
3.5.6-bit operator: non-focus
3.5.73-dollar operator
This is the only ternary operator in Java, with three operands.
Example: Boolean b=20<45?true:false;
3.5.8 Operation Priority
Parentheses Maximum!!! Minimum copy operator!!!
3.5 operator