Traditional Culture Encyclopedia - Traditional stories - Three kinds of loop control statements in java process control statements

Three kinds of loop control statements in java process control statements

These are for loop, while loop and do…while loop.

For loop, such as for(int? I = 0; I<5; i++){ }; Cycle from 0, add 1 at a time, and end at 4.

While loop, such as while (true) {}; That is, when the condition is true, it will be executed, otherwise it will not be executed at one time.

Do…while loop, such as do {I = 0;; system . err . println(I)} while(I & gt; 1){}; In this case, even if the conditions are not met, the statements in do will be executed, which is suitable for the difference between while.

Remarks: The specific cycle can be selected according to actual needs.