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

How to use the continue statement in java

WBOY
WBOYforward
2023-04-26 11:43:154308browse

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);

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete