java的循环

java的for循环

for循环的条件控制语句可以拿出来进行操作

 

                     

 

执行流程文件叙述:

                

 

 eg:

public class helloword {
    //快速生成"psvm"  生成如下
    public static void main(String[] args) {
        //快速生成"sout" 生成如下
        //switch
        for (int i = 1; i < 5; i++) {
            System.out.println("我爱你亲爱的姑娘");
        }
    }
}

Java的while循环

 

eg:

public class helloword {
    //快速生成"psvm"  生成如下
    public static void main(String[] args) {
        //快速生成"sout" 生成如下
        //switch
        int count=0;
        while (count<100){
            count++;
            System.out.println(count);
        }
    }
}

do...while循环语句格式

 

 无限循环

 

 eg:

t跳过本次循环同py--->continue;停止循环同py是关键字break;

public class helloword {
    //快速生成"psvm"  生成如下
    public static void main(String[] args) {
        //快速生成"sout" 生成如下
        //switch
        for (int a=1;a<100;a++){
            if(a==2){
                continue;
            }
            System.out.println(a);
        }
    }
}

 

 

posted @ 2022-05-13 17:16  欧阳锦涛  阅读(37)  评论(0)    收藏  举报
TOP 底部