Home > Java > javaTutorial > How to use the continue statement in java

How to use the continue statement in java

WBOY
Release: 2023-04-26 11:43:15
forward
4333 people have browsed it

Explanation

1. The continue statement refers to skipping the remaining statements in the loop and forcing the execution of the next loop. Its function is to end the loop, that is, skip the remaining statements in the loop. There are no executed statements, and then it is judged whether the next loop is executed.

2. The continue statement is similar to the break statement, but it can only appear in a loop.

Example

int sum = 0;
for (int i = 1; i <= 100; i++) {
    if (i % 2 == 0) {
        continue;
    }
    sum += i;
}
System.out.println("1到100之间的奇数和为:" + sum);
Copy after login

The function of continue is to skip the execution of this loop, jump directly to i, then judge i<=100, and enter the loop body again.

What can Java be used for?

Java is mainly used in:

1. Web development;

2. Android development;

3. Client development;

4. Web page development;

5. Enterprise-level application development;

6. Java big data development;

7 .Game development, etc.

The above is the detailed content of How to use the continue statement in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template