java loop statement: 1. while loop, the code is [while (judgment condition) {loop body (one or more statements)}]; 2. do while loop, the code is [do{loop body}] ]; 3. for loop, the code is [for (declaration of loop increment; judgment condition; increment by itself) {loop body}].
The operating environment of this tutorial: windows7 system, java10 version, DELL G3 computer. This method is suitable for all brands of computers.
java loop statement:
1. while loop
Basic structure
while(判断条件){ 循环体 (一条或多条语句) } 当判断条件不成立时循环结束
2. do-while loop
Basic structure
* do{ * 循环体 * }while(判断条件) * do-while循环 不管判断条件是否成立 * 都会先执行循环体一次
3. for loop
Basic structure
for(声明循环增量;判断条件;增量自增){ 循环体 } for(int i = 0; i < 5; i++){ sout("循环内"); } sout("循环外");
Difficulties :Nested for loop
for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { sout("内循环"); } sout("外循环"); } sout("循环外");
Related free learning recommendations:java basic tutorial
The above is the detailed content of What are the java loop statements?. For more information, please follow other related articles on the PHP Chinese website!