Home> Java> JavaBase> body text

What are the java loop statements?

coldplay.xixi
Release: 2023-01-13 00:39:48
Original
27196 people have browsed it

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}].

What are the java loop statements?

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(判断条件){ 循环体 (一条或多条语句) } 当判断条件不成立时循环结束
Copy after login

2. do-while loop

Basic structure

* do{ * 循环体 * }while(判断条件) * do-while循环 不管判断条件是否成立 * 都会先执行循环体一次
Copy after login

3. for loop

Basic structure

for(声明循环增量;判断条件;增量自增){ 循环体 } for(int i = 0; i < 5; i++){ sout("循环内"); } sout("循环外");
Copy after login

Difficulties :Nested for loop

for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { sout("内循环"); } sout("外循环"); } sout("循环外");
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!