The difference between three types of loops
(Learning video sharing: java course)
Judge first between for loop and while loop Whether the condition is true, then decide whether to execute the loop body (judge first and then execute)
do...while loop first executes the loop body once, and then determine whether the condition is true, and whether to continue executing the loop body (execute first and then judge)
The difference between for loop and while
The auto-increment variable controlled by the conditional control statement, because of the syntax structure of the for loop, cannot be accessed again after the for loop ends
The self-increasing variable controlled by the conditional control statement does not belong to the syntax structure of the while loop. After the while loop ends, the variable can continue to be used
Infinite loop (infinite loop) Three formats
for(){} while(true){} do {} while(true);
Related recommendations:Getting started with java
The above is the detailed content of What are the differences between the three loop structures in java. For more information, please follow other related articles on the PHP Chinese website!