JAVA-control process, java Process
In Java, you must declare a public class of the main () method. The program starts execution from the first statement of the main () method, and then executes subsequent statements one by one until it reaches the end of the program-the end of the main () method. However, during program design, we often need to change the program control process, that is, the statement execution sequence. There are three basic technologies that can change the control process of a program:
1,Call Method. The caller will cause the control flow to exit the current method and transfer it to the called method. For example, when we call println (), the control program leaves main (), switches to println (), and returns the main () method when the execution is complete.
2,Select.Java has two options: if/else statements and switch statements. The three-object operator can also be used for selection, but it is usually only a short version of if/else.
3,Loop.Java has three types of loop statements: for Loop, while loop, and do/while loop.
For Jump statements break and continue:
The break keyword can be used in any loop control structure,So that the cycle ends immediately.
The continue keyword can be used in any soul control structure, which causesThe loop immediately jumps to the next iteration of the loop.
Note:In Java, excessive use of break and continue statements is not recommended. The two keywords appear in Java mainly because they are used by C and C ++. They have a certain purpose, especially the break keyword. However, in many cases, we can redesign the code to avoid using break and continue.