4.1 True and False
All conditional statements are judged by true and false.
4.2 If-else
if (BOOL-EXP) statement; or if (BOOL-EXP) statement; else statement;
4.3 iterations
while (b) {} do{}while (b)
for (init;b;step) {}init You can define multiple initial variables with commas
4.4 foreach Syntax
Enhanced for loop for (T T: Collection/array) {}
4.5 Return
4.6 Break and continue
Any iteration statement body can use break and continue to control the loop flow.
can be used with tags: interrupts the loop until the label is in place.
Note: The only reason to use tags in Java is because there is a loop nesting, and you want to break or continue from multiple nested nesting;
4.7 Infamous Goto
4.8 Switch
Depending on the integer expression, you can choose one from a series of code to execute.
Switch (INT-EXP) {
Case Int-val1:st1; Break
...
DEFAULT:SN;
Integer expressions include byte, short, char, int , and encapsulated classes and enums
Note: Starting with 1.7 string can also be, the principle is to convert a string to hashcode as an int to handle
}
Java Programming Idea: The 4th Chapter controls the execution flow