Java language Looping statements
for (expression 1 (parameter initialization), Expression 2 (conditional), expression 3 (update loop variable)) {
Statement loop operation;
}
First, the initialization of the parameters, the next condition to determine, (conditions), and then perform the loop operation, and then update the loop variable, to do the conditional judgment (condition), and to perform the loop operation;
One, the three elements of the loop 1, the loop variable 2, the cycle condition 3, the loop body two, the Do-while cycle (first cycle, then judge, at least one cycle) do{statement;}while (condition); three, while loop (first judgment, recirculation, possibility of not looping at one time) while (condition) {statement ;} Four, for loop structure * * * Three clauses in parentheses are integral. Three clauses can be empty statements, separated by semicolons. A semicolon for (statement 1; loop condition; statement 3) {statement 2;} is used between the loop body and the for Five, exit loop break: End the entire loop continue: end this cycle
Go language Loop statementThere are a few things to keep in mind when using loop statements. The left curly brace {must be in the same row as the for.? The For loop in the go language, like the C language, allows you to define and initialize variables in a looping condition, except that the go language does not support multiple assignment statements separated by commas, and you must initialize multiple variables using parallel assignments. The For loop of the Go language also supports continue and break to control loops, but it provides a more advanced breaks that can optionally interrupt which loop, as in the example: for j: = 0; J < 5; J + + {for I: = 0, I <; i++ {if i > 5 {break Jloop} fmt. Println (i)}}jloop://... In this example, the break statement terminates the outer Loop at the Jloop label. 4. Jump Statement Gotofunc MyFunc () {i: = 0 here:fmt. Println (i) i++ if I < {goto here}}5,defer statements follow the first call after execution, followed by the first execution of the law.
The difference between the Java language Foundation and the Go Language Foundation and the cyclic statements