Java Control statements

Source: Internet
Author: User

program = data + algorithm

So, the data type solves the data operation problem, what solves the algorithm problem? Obviously, each programming book directory is basically the first data type after the control statements such as editing. Therefore, the implementation of the algorithm depends on the control statement.

The control statement, as the name implies, is the role of the control process. In real life, the process of doing things, in addition to parallel, the basic is only three ways, order, conditions, circulation.

Order, very simple, and basically all programming languages are running from the beginning of the program, the order of the next statement of the execution of a statement, this does not jump, one by one execution mode, is the sequential mode.

conditions, which are common in life, especially when doing math problems, have a way of classifying discussions, for example, if a>0, then .... If a<0, then ...., if a=0, then ...; This is the obvious conditional branching pattern.

Cycle, in the running time is very obvious, such as running around the playground 10 laps, then the athlete is constantly circulating, until 10 laps, stop. This is the loop.

Because the order is to write code next to each other, there is nothing to say, there is no keyword expression. So I skipped it.

Two other types of code are:

Class logic{public void logic () {if (logical expression) {//statement;} if (logical expression) {//statement;} else{//statement;} if (logical expression) {//statement;} else if (logical expression) {//Statement}...else{//statement;} while (validation condition) {//statement;} While is the first check the condition and then judge whether the loop, Do-while is to execute//once again to determine whether the next loop do{//statement;} while (validation condition); The/*while loop always places the iteration statement in its code block. The For Loop places the iteration statement in the conditional parentheses. As a result, while looping through the continue statement, the iteration statement will not execute when the loop is closed. But for loops, even if you use the Continue statement to end the loop, the iteration statement will still execute. */for (initial condition; validation condition; Iteration statement) {//statement;} /*** continue ends the remaining statement in this loop, the next loop is executed * The break statement is the end of the entire loop. */}}


This article is from the "http://sunshine2624.blog.51cto.com/3959438/1875615" blog, please be sure to keep this source.

Java Control statements

Related Article

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.