Java programming 30-Process Control Basics

Source: Internet
Author: User

Java programming those things 30-Process Control basics Zhengzhou game college Chen yuefeng from: http://blog.csdn.net/mailbomb Chapter 5 Process ControlA process refers to the execution sequence of a program, and a process control refers to the function of implementing the requirements by controlling the execution sequence of the program. The process control part is the combination of language and logic in the program, the most flexible part of the program, is the main aspect of judging a programmer's ability. As we all know, algorithms are the core of program logic, and most of the code of algorithms is implemented by process control. Process control refers to the process of describing the programmer's solution to the problem by using the syntax format of the programming language. 5.1 Process Control BasicsProcess control is implemented through three types of control statements in the programming language: l ordered statements are natural statements without specific syntax formats, the overall execution process is to first execute the written code, and then execute the written code. When using ordered statements, pay special attention to the code execution sequence. L conditional statements, also known as judgment statements or branch statements, have the corresponding syntax format in the program. The execution flow determines whether the code is executed Based on the condition. If the condition is true, the code is executed. Otherwise, the Code is not executed. When using conditional statements, pay special attention to the accuracy of the conditions and the writing of functional parts. L a loop statement is a computer-specific statement that refers to the code that is repeatedly executed and has a corresponding syntax format in the program. The execution process is to determine whether the condition is true each time, then decide whether to repeat the execution. Loop statements are the most flexible and complex part of process control and the most powerful type of statements. When using cyclic statements, pay attention to the writing of the cyclic conditions and functions. In a program, any complicated process can only be implemented through the combination and nesting of the above three types of statements. Therefore, when learning process control, first, you need to have a basic understanding of the three types of statements, then familiarize yourself with the relevant syntax, conduct targeted exercises, and finally use these three types of statements flexibly to solve practical problems. In addition, it should be emphasized that, according to the logic needs, various statements can be nested at will, that is, other statements can be written inside a statement, which can implement more complex logic. Subsequent explanations are also conducted in this order, and some process control exercises are attached to this section. 5.2 sequential statementsA sequential statement is the simplest type of statement in a flow control statement. It does not have a syntax format in the code. You only need to write it in sequence according to the logic sequence. Therefore, before writing it, first, you must think clearly about the corresponding logical order and then start the corresponding writing. Note that in actual code, code writing may affect the logic of the program, for example, the code output below. Sample Code 1: int n = 10; n + = 2; system. out. println (n); Sample Code 2: int n = 10; system. out. println (n); N + = 2; the output value of sample code 1 is 12, even if the code is the same, the output value in sample code 2 is 10. Similar logic also exists in actual projects.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.