Java series (5)-process control statements and java statements
1. Ordered Structure
1. if statement
(1) legend
(2) three formats
A: Format 1
B: Format 2
C: Format 3
2. swich statement
Legend:
Format:
[Note] the input value can be byte, short, int, char, enumerative after JDK5, and string after JDK7;
3. Loop statements
Legend:
(1) for Loop
(2) while Loop
Legend:
Usage:
(3) do... While Loop
Legend:
Usage:
(4) differences between for and while
A: usage differences
[The control condition variable of the for statement cannot be used after the loop ends, but the while statement can be used again]
B: differences in understanding
[For is suitable for the determination of a range, while is suitable for loops with unclear numbers]
(5) differences between the three cycles
A: do... The while LOOP must be executed at least once.
B: for and while must first determine whether the condition is true before deciding whether to execute a loop
4. Control jump statements
(1) break: Meaning of Interruption
A: It is used in loop and switch statements, and the exit application scenario is meaningless.
B: role:
[A. Jumping out of a single loop]
[B. jump out of a multi-layer loop and use the tag statement together]
(2) continue: continue
Purpose: jump out of a loop and enter the next execution.
(3) return: return
A: Used to end method execution.
B: The program will not be executed in the future if return is encountered.