Operation: The process of manipulating constants and variables is called arithmetic.
Number of operations: The constant or variable that participates in the operation is called the operand.
Operator: symbols that operate on constants and variables are called operators.
Arithmetic operators: + 、-、 *,/,%, + + 、--
/and% of the difference?
/: Division, get quotient
The same symbol is positive and the difference is negative
%: Division, get remainder
The symbol is the same as the first operand
% of applications:
x%3 equals 0 means x can be divisible by 3.
x%2 etc 1 description x is odd
Wait 0 to indicate that X is an even number
+ +,--operator
Function: + + is added 1,--is minus 1.
Self-increment auto-decrement operator
+ +,--can be placed in front of the operand, or after the operand, at the time of operation
A: Use alone
No difference.
B: Participate in other operations using
Back: First operation, then self-increment
Front: Self-increment first, then operate
Assignment operators
Basic: =
Extension: + =
The extended assignment operator implies a forced type conversion:
int a = 10;
A + = 20;
A = (data type of a) (A + 20)
comparison Operators :
==,!=,>,>=,<,<=
Attention:
A: The result of the comparison operator is definitely a Boolean.
B: Whether you are using "=" or "= =", you need to know for yourself.
logical operators : &, |,! , ^, &&, | |
Attention:
logical operators for connecting relationship expressions
Conclusion:
&: False if False
|: True is true
!: Change the result, take the inverse
^: same false, different true
Memory: Couple relationship (male, female, male, female)
The most commonly used logical operators;
!,&&,| |
&& and &:
The result is the same, but the && has a short-circuit effect, the left side is false and the right side is not executed.
|| and |:
As a result, but | | With short-circuit effect, left if true, the right side is not executed.
Trinocular operator
Format:?:
(comparison expression)? Expression 1: Expression 2;
Execution process:
If the condition is true, the result of the operation is an expression of 1;
If the condition is false, the result of the operation is an expression of 2;
Requirements: Get the maximum value from two data
Nested use (Gets the maximum of three numbers)
An expression: a formula that joins a constant or variable with an operator that conforms to the Java syntax can be called an expression.
The expressions of different operator joins represent different types of expression.
Java Learning: Operations, operators, operands, expressions