Operator arithmetic operators:
Addition (+) subtraction (-) multiplication (*) Division (/) modulus (%)
Addition:
String type: concatenation of strings.
Division:
1.0/0 Display Infinity Infinity
0.0/0.0 Show Nan:not A number is not a numeric value
0.0/0.0 = = 0.0/0.0 in Java itself is not equal to its own condition result is false
The modulo is also called the surplus
Self-increment/decrement:
Self-increment decrement can only be used for variables: operators have precedence over other operators.
Operation rules:
1. The self-increment is counted for the variable itself (i++ ++i)
The value of the variable is increased from 1
2. Assign a value to another variable using the result of a variable and an expression of the self-increment operator
A The increment operator is on the right: the result of the expression is the original value of the variable, as the result of the expression. The variable will still be self-increasing
Two The increment operator is on the left: the result of the expression is the value of the variable's original value since the increment, as the result of the expression. The variable will still be self-increasing
3. Assign a variable to the variable itself using the result of an expression of the increment operator
y=y++: The result of the expression is cached, then self-increment, and finally the result of the expression is assigned to Y
Y=++y: The result of the expression is the increment of the original value of the variable, and finally the result of the expression is assigned to Y
Assignment operators:
The operation symbols are: = + = = *=/=%=
Assign value from right to left
There is an implicit conversion, such as I *= 2.0 can only be seen as I = i * 2.0 The actual result is a defined int type
Comparison operators
Symbols: = = = = > < >= <= instanceof ( Type comparison operator, only for reference type data comparisons)
Attention:
- The result type of the comparison operator expression is Boolean
- = = = > < >= <= is a two-tuple operator with only two operands
- Instanceof is to determine whether an object belongs to a certain kind of type
instanceof Rules of Operation:
Value variable or expression to be instanceof type
logical operators
& (And) | (or) &&(dual vs. logic) | | (dual or logical OR) ^ different or ! Non -
Rules for logical operators:
&: Both sides are true and the result is true
|: As long as one side is true, the result is true
&&: Both sides are true and the result is true
| |: As long as one side is true, the result is true
^: Different sides, the result is true, otherwise false
! : Logical Non-
1. Both parameters and the data type of the operation are of type Boolean
2. The result type of the logical operator expression is Boolean
The role of logical operators:
Is the combination judgment applied to multiple conditions.
&& | | and the difference between & |:
& | can either act as a logical operation, or it can be a bitwise operator
Determines whether the result of an expression is a Boolean type
&& | | There is a short-circuit behavior:
&&: When the current face is false, the result of the entire expression is false and the expression after it is no longer operational
|| : When the current face is true, the expression after the whole expression is true is not an operation
Bit operations (understanding)
Concept: Binary is an operation that sees 1 as true and 0 as false.
Trinocular Operations: Syntax:
A? B:c
A: A Boolean-type expression
The result types of B and C are generally the same
Rules
According to the result of a: if true, the result of the whole trinocular operator expression is the result of the B-expression
If False, the result of the expression of the entire Trinocular operator is the result of the C-expression
Attention:
The trinocular operator requires a variable to receive
Java arithmetic operations