1. Operator 1. operator
1) arithmetic operator: +,-, *,/,%,++,--
++/--: Self-increment 1/decrement 1, can be placed before and after variables
1.1) ++/--When used alone, no difference in front
1.2) If the ++/--is used, there is a difference in the former
1.2.1) + + in the rear, first use, then self-increment
1.2.2) + + in front, first self-increment, then use
2) relational operator:> (greater than),< (less than), >= (greater than or equal to), <= (less than or equal to), = = (equals),! = (Not equal)
The result of a relational operation is a Boolean type,
True if the relationship is established, false if the relationship is not valid
3) logical operator:&& (short circuit and), | | (short circuit or),! (Logical non)
& (non-short circuit and), | (non-shorted or)
The logical operation is based on the relational operation,
The result of the logical operation is also the Boolean type
&&: Both sides are true and false is False
A short circuit when the first number is false (no subsequent execution)
| |: One side is true and true is True
A short circuit when the first number is true (no subsequent execution)
!: Non-True or false, true
4) assignment Operator: =
Extended assignment operator +=,-=,*=,/=,%=
It is recommended to use the extended assignment operator because of its high efficiency
5) string concatenation: +
+ number If both sides are numbers, do the addition operation
+ If one side is a string, do string concatenation
6) Three mesh operator: Boolean? Number 1: Number of 2
Execution process:
To calculate the Boolean value:
If true, the entire result is 1
If False, the entire result is 2
2. Branching structure: Conditional execution of a statement--------not every word must go
1) If:1 Road
2) If...else:2 Road
3) If...else if: Multiple paths
4) Switch...case: multiple routes
Advantages: Clear structure and high efficiency
Cons: integral type, judged equal
Break: Jump out of Switch...case