Java serialized 22-for circulation

First, the loop structure

In the program there are always some of them require repeated / repetitive code execution, assuming no loop structure, then this needs to repeat the formula of the code naturally most in need of rewriting the code can not be reused, so the majority of programming languages ​​are supporting loop structure, the future code needs to be executed repeatedly into the "loop", and then combined "counter", the common control codes need to repeatedly perform this.

1. Basically all of the programming languages ​​supported include three cycles:

(1) for cycles; (2) while loop; (3) do ..... while loop.

2. The main explanation for the current example loops, for loops grammatical structure of what it is:

grammar structure

 

for (initial expression; Boolean expression; updating expression) { 

    // need snippet [loop repeatedly performed: java statement consists} 

}

 

 

3.for execution cycles / execution principle

(1) initialization expressions, Boolean expressions, updated expressions are not necessary to write, but must follow the two semicolons are.

(2) an initialization expression is executed first, and is performed only once in the entire cycle for

(3) the Boolean expression must be true / false, not other values.

Implementation process (4) for the

i. to perform the initialization expression, and this expression only once

ii. determine the result of a Boolean expression is true or false

III. Boolean expression is true, the loop body is executed, performs updating expression, the Boolean expression is determined again.

iv. Boolean expression is false, the loop ends.

4. Examples:

 

@ Demand: Digital output 10 ~. 1 

    for ( int i = 0; i <= 10; i ++) { // variables for loop i from among the limited scope for use in the current loop in 

      System.out .println (I); 

    }

 

5. nested loop

The inner loop variable names and names must be unique in the outer loop.

Not a very simple example.                                                                                 

Third, the source code:

d22_for_circulation.java

address:

https://github.com/ruigege66/Java/blob/master/d22_for_circulation.java

2.CSDN: https: //blog.csdn.net/weixin_44630050 (Xi Jun Jun Moods do not know - Rui)

3. Park blog: https: //www.cnblogs.com/ruigege0000/

4. Welcomes the focus on micro-channel public number: Fourier transform, backstage reply "gifts" to get big data learning materials

 

 

Guess you like

Origin www.cnblogs.com/ruigege0000/p/11427465.html