循环练习

/*
public class First {
public static void main(String[] args) {
int sum = 0;
for (int i = 1;i<=100;i++){
if (i%2 == 0){
sum += i;
}
} System.out.println("结果是:"+ sum );
}
}
*/break结束

public class First {
public static void main(String[] args) {
for (int i = 1;i <= 10;i++){
if(i==4){
break;//直接结束!
}
System.out.println("石海兵使我儿"+ i);

}
}
}
/*cotinue跳过

public class First {
public static void main(String[] args) {
for (int i = 1;i <= 10;i++){
if(i==4){
continue;//跳过第四层执行下一层
}
System.out.println(i + "层到了");
}
}
}
 /*死循环
格式
while(true){
循环体语句;
}

public class First {
public static void main(String[] args) {
while (true){
System.out.println("傻逼石海兵");
}
}
}
/*循环嵌套

public class First {
public static void main(String[] args) {

for (int h=0;h<24;h++){
for (int m =0;m<60;m++){
System.out.println(h+"时"+m+"分");
}
}
}
}
 
 
posted @ 2021-03-31 20:34  小陈的orange  阅读(27)  评论(0编辑  收藏  举报