{"id":710,"date":"2023-03-23T21:50:23","date_gmt":"2023-03-23T13:50:23","guid":{"rendered":""},"modified":"2023-03-23T21:50:23","modified_gmt":"2023-03-23T13:50:23","slug":"Java Continue\u8bed\u53e5","status":"publish","type":"post","link":"https:\/\/bianchenghao6.com\/710.html","title":{"rendered":"Java Continue\u8bed\u53e5"},"content":{"rendered":"


\n <\/head>
\n <\/p>\n

\n

Java Continue\u8bed\u53e5<\/h1>\n<\/p><\/div>\n
\n \u5f53\u60a8\u9700\u8981\u7acb\u5373\u8df3\u8f6c\u5230\u5faa\u73af\u7684\u4e0b\u4e00\u4e2a\u8fed\u4ee3\u65f6\uff0c\u5c06continue\u8bed\u53e5\u7528\u4e8e\u5faa\u73af\u63a7\u5236\u7ed3\u6784\u4e2d\u3002\u5b83\u53ef\u4ee5\u4e0efor\u5faa\u73af\u6216while\u5faa\u73af\u4e00\u8d77\u4f7f\u7528\u3002\n <\/div>\n
\n Java
\n continue\u8bed\u53e5<\/em>\u7528\u4e8e\u7ee7\u7eed\u5faa\u73af\u3002\u5b83\u7ee7\u7eed\u7a0b\u5e8f\u7684\u5f53\u524d\u6d41\u7a0b\uff0c\u5e76\u5728\u6307\u5b9a\u6761\u4ef6\u4e0b\u8df3\u8fc7\u5176\u4f59\u4ee3\u7801\u3002\u5982\u679c\u662f\u5185\u90e8\u5faa\u73af\uff0c\u5219\u4ec5\u7ee7\u7eed\u5185\u90e8\u5faa\u73af\u3002\n <\/div>\n
\n \u6211\u4eec\u53ef\u4ee5\u5728\u6240\u6709\u7c7b\u578b\u7684\u5faa\u73af(\u4f8b\u5982for\u5faa\u73af\uff0cwhile\u5faa\u73af\u548cdo-while\u5faa\u73af)\u4e2d\u4f7f\u7528Java continue\u8bed\u53e5\u3002\n <\/div>\n
\n \u8bed\u6cd5: <\/strong>\n <\/div>\n
\n
 jump-statement;
continue<\/span>;
<\/span><\/code><\/pre>\n<\/p><\/div>\n

Java\u7ee7\u7eed\u8bed\u53e5\u793a\u4f8b<\/h2>\n
\n \u793a\u4f8b: <\/strong>\n <\/div>\n
\n
 Example {
    public <\/span>static void <\/span>main(String[] args) {
        \/\/for <\/span>loop
        for(int i=1;i<=10;i++){
            if(i==5){
                \/\/using continue statement continue;
            \/\/it will skip the rest statement }
            System.out.println(i);
        }
    }
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa:\n <\/div>\n
\n
\n
 1
2
3
4
6
7
8
9
10
<\/span><\/code><\/pre>\n<\/p><\/div>\n<\/p><\/div>\n
\n \u5982\u4e0a\u9762\u7684\u8f93\u51fa\u6240\u793a\uff0c\u63a7\u5236\u53f0\u4e0a\u672a\u6253\u53705\u3002\u8fd9\u662f\u56e0\u4e3a\u5230\u8fbe5\u70b9\u65f6\u5faa\u73af\u4f1a\u7ee7\u7eed\u3002\n <\/div>\n

\u5e26\u6709\u5185\u90e8\u5faa\u73af\u7684Java Continue\u8bed\u53e5<\/h2>\n
\n \u4ec5\u5f53\u60a8\u5728\u5185\u90e8\u5faa\u73af\u4e2d\u4f7f\u7528continue\u8bed\u53e5\u65f6\uff0c\u5b83\u624d\u80fd\u7ee7\u7eed\u5185\u90e8\u5faa\u73af\u3002\n <\/div>\n
\n \u793a\u4f8b: <\/strong>\n <\/div>\n
\n
 public <\/span>static void <\/span>main(String[] args) {
    \/\/ outer loop
    for(int i=1;i<=3;i++){
        \/\/inner loop
        for(int j=1;j<=3;j++){
            if(i==2&&j==2){
                \/\/using continue statement inside inner loop continue;
            }
            System.out.println(i+\" \"+j);
        }
    }
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa:\n <\/div>\n
\n
\n
 1 1
1 2
1 3
2 1
2 3
3 1
3 2
3 3
<\/span><\/code><\/pre>\n<\/p><\/div>\n<\/p><\/div>\n

\u6807\u6709For\u5faa\u73af\u7684Java Continue\u8bed\u53e5<\/h2>\n
\n \u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u5e26\u6709\u6807\u7b7e\u7684continue\u8bed\u53e5\u3002\u6b64\u529f\u80fd\u662f\u4eceJDK 1.5\u5f00\u59cb\u5f15\u5165\u7684\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u7ee7\u7eedJava\u4e2d\u7684\u4efb\u4f55\u5faa\u73af\uff0c\u65e0\u8bba\u662f\u5916\u90e8\u5faa\u73af\u8fd8\u662f\u5185\u90e8\u5faa\u73af\u3002\n <\/div>\n
\n \u793a\u4f8b: <\/strong>\n <\/div>\n
\n
 public <\/span>class \ncontinue<\/span>Example3 { \n
     \npublic <\/span>static \n void <\/span>main(String[] args) { \n
        aa: for(int i=1;i<=3;i++){ \n
            bb: for(int j=1;j<=3;j++){ \n
                if(i==2&&j==2){ \n
                    \/\/using continue statement with label continue aa; \n
                } \n
                System.out.println(i+\" \"+j); \n
            } \n
        } \n
    } \n
} \n
<\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa:\n <\/div>\n
\n
\n
 1 1
1 2
1 3
2 1
3 1
3 2
3 3
<\/span><\/code><\/pre>\n<\/p><\/div>\n<\/p><\/div>\n

while\u5faa\u73af\u4e2d\u7684Java Continue\u8bed\u53e5<\/h2>\n
\n \u793a\u4f8b: <\/strong>\n <\/div>\n
\n
 WhileExample {
    public <\/span>static void <\/span>main(String[] args) {
        \/\/while loop int i=1;
        while(i<=10){
            if(i==5){
                \/\/using continue statement i++;
                continue;
            \/\/it will skip the rest statement }
            System.out.println(i);
            i++;
        }
    }
}
<\/span><\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa:\n <\/div>\n
\n
\n
 1
2
3
4
6
7
8
9
10
<\/span><\/code><\/pre>\n<\/p><\/div>\n<\/p><\/div>\n

do-while\u5faa\u73af\u4e2d\u7684Java Continue\u8bed\u53e5<\/h2>\n
\n \u793a\u4f8b: <\/strong>\n <\/div>\n
\n
 continue<\/span>DoWhileExample { \n
     \npublic <\/span>static \n void <\/span>main(String[] args) { \n
        \/\/declaring variable int i=1; \n
        \/\/do- \nwhile <\/span>loop do{ \n
            if(i==5){ \n
                \/\/using \ncontinue<\/span> statement i++; \n
                 \ncontinue<\/span>; \n
            \/\/it will skip the \nrest <\/span>statement } \n
            System. \nout.println<\/span><\/span>(i); \n
            i++; \n
        } \n
        while(i<=10); \n
    } \n
} \n
<\/code><\/pre>\n<\/p><\/div>\n
\n \u8f93\u51fa:\n <\/div>\n
\n
\n
 1
2
3
4
6
7
8
9
10
<\/span><\/code><\/pre>\n<\/p><\/div>\n<\/p><\/div>\n

<\/body>
\n<\/html><\/p>\n","protected":false},"excerpt":{"rendered":"Java Continue\u8bed\u53e5zh-cn","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111],"tags":[],"class_list":["post-710","post","type-post","status-publish","format-standard","hentry","category-java-jichu"],"_links":{"self":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/710"}],"collection":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/comments?post=710"}],"version-history":[{"count":0,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/posts\/710\/revisions"}],"wp:attachment":[{"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/media?parent=710"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/categories?post=710"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bianchenghao6.com\/wp-json\/wp\/v2\/tags?post=710"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}