美文网首页
Continue02 细节

Continue02 细节

作者: 哈迪斯Java | 来源:发表于2021-10-17 15:27 被阅读0次

    package HspLearning;

    public class Continue02 {
    public static void main(String[] args) {
    label1:for(int j = 0;j < 4; j++){
    label2:for(int i = 0;i < 10; i++){
    if(i== 2){
    continue label1;
    }
    System.out.println("i = " + i);
    }
    }

    }
    

    }
    结果===
    i = 0
    i = 1
    i = 0
    i = 1
    i = 0
    i = 1
    i = 0
    i = 1

    ======================

    package HspLearning;

    public class Continue02 {
    public static void main(String[] args) {
    label1:for(int j = 0;j < 4; j++){
    label2:for(int i = 0;i < 10; i++){
    if(i== 2){
    continue label2;
    }
    System.out.println("i = " + i);
    }
    }

    }
    

    }
    结果为==
    i = 0
    i = 1
    i = 3
    i = 4
    i = 5
    i = 6
    i = 7
    i = 8
    i = 9
    i = 0
    i = 1
    i = 3
    i = 4
    i = 5
    i = 6
    i = 7
    i = 8
    i = 9
    i = 0
    i = 1
    i = 3
    i = 4
    i = 5
    i = 6
    i = 7
    i = 8
    i = 9
    i = 0
    i = 1
    i = 3
    i = 4
    i = 5
    i = 6
    i = 7
    i = 8
    i = 9

    相关文章

      网友评论

          本文标题:Continue02 细节

          本文链接:https://www.haomeiwen.com/subject/fjlwoltx.html