search
HomeJavaJavaBaseWhat is the function of continue statement

What is the function of continue statement

Jul 11, 2020 am 09:13 AM
continueeffect

The function of the continue statement is to end the current loop and enter the next loop. That is, only this loop ends, not all loops end, and subsequent loops still proceed. The continue statement can only be used in loop statements.

What is the function of continue statement

In Java language, the continue statement is used to end the current loop and enter the next loop. That is, only this loop ends, not all loops end. , the subsequent loop still proceeds.

(Recommended tutorial: java entry program)

Let’s take a look at an example:

public class Continue {
    public static void main(String[] args) {
        int count = 0;
        for(int i = 1; i <= 10; i++) {
            if(i == 5) {
                // 遍历到5的时候,就会跳过当前循环体,当然也不会去执行剩下的语句了。
                // 于是就到了下一轮循环(此时i的值是6),所以这里的第5次输出是6而非5,因为5的那一轮循环被跳过了。
                continue;
            }
            count++;
            System.out.println("第" + count + "次输出,输出值为" + i);
        }
    }
}

(Recommended video tutorial: java video Tutorial)

Output result:

What is the function of continue statement

The above is the detailed content of What is the function of continue statement. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.