Process Control:
1. Sequential structure
2. Branching structure: A logical expression in (), code executed when the logical expression is true in {}
if () {};
if () {}else{};
if () {}else if () {};
Switch () case value 1: code block;
3. Loop structure:
Four parts: variable initialization, loop condition, loop body, variable iteration
Keyword: The entire loop of the loop body where break ends
Continue end of the cycle in which the loop body is located
while () {}
Do{}while ();
For () {}
Foreach
4. If and switch differences:
1). Switch performance is much higher than if;
2). Switch can only make equivalent judgments;
3). The case in switch must be followed by a break;
4). Switch can do if all can do;
5. The switch statement has the following rules:
1) The variable type in the. Switch statement can only be a data type (byte, short, int, or char) that is less than 32 bits, and an enumeration type, as well as a string type in JDK 7.
2). Switch statements can have multiple case statements. Each case is followed by a value and a colon to compare.
3). The data type of the value in the case statement must be the same as the data type of the variable, and can only be constants or literal constants.
4). When the value of a variable is equal to the value of the case statement, the statement after the case statement starts executing until the break statement appears and jumps out of the switch statement.
5). When a break statement is encountered, the switch statement terminates. The program jumps to the statement following the switch statement execution. The case statement does not have to contain a break statement. If no break statement appears, the program continues to execute the next case statement until a break statement appears.
6) the. Switch statement can contain a default branch, which must be the last branch of the switch statement. Default is executed when there is no case statement with the value equal to the value of the variable. The default branch does not require a break statement.
7). If there is no break, the program starts execution from the first qualifying point until the default (the switch is penetrated). It is recommended that you add a break below each branch, but you can sometimes take advantage of this feature.
6. Operators used in logical expressions
The conditional operator:>,>=,<, <=,! =, = =,
Common operation of two conditions or multiple conditions: &&, | |,!
7. Inline loop (not summarized)
Java Process Control