java:break与continue的区别
break是结束当前循环,continue是结束本次循环,不结束当前循环。
public class Fighting {
public static void main(String[] args) {
for(int i = 1;i <= 9;i++) {
if(i % 3 == 0) {
break;
}
System.out.print(i+"\t");
}
}
}
public class Fighting {
public static void main(String[] args) {
for(int i = 1;i <= 9;i++) {
if(i % 3 == 0) {
continue;
}
System.out.print(i+"\t");
}
}
}
来源:CSDN
作者:bear xiao
链接:https://blog.csdn.net/weixin_44750594/article/details/104174753