在循环中遇到不符合条件的情况,是否应该跳出当前循环?
- 内容介绍
- 文章标签
- 相关推荐
本文共计645个文字,预计阅读时间需要3分钟。
一、break语句+1、用法:+出现在switch语句或循环体中,使程序从循环体和switch语句内跳出,继续执行循环体或switch语句后的下一条语句。+注意:break语句不宜用在else处。
二、实例:javaint a=1;switch (a) { case 1: System.out.println(case 1); break; case 2: System.out.println(case 2); break; default: System.out.println(default);}
一、break语句
1、用法:
出现在switch语句或循环体中,使程序从循环体和switch语句内跳出,继续执行逻辑上的下一条语句,break语句不宜用在别处。
本文共计645个文字,预计阅读时间需要3分钟。
一、break语句+1、用法:+出现在switch语句或循环体中,使程序从循环体和switch语句内跳出,继续执行循环体或switch语句后的下一条语句。+注意:break语句不宜用在else处。
二、实例:javaint a=1;switch (a) { case 1: System.out.println(case 1); break; case 2: System.out.println(case 2); break; default: System.out.println(default);}
一、break语句
1、用法:
出现在switch语句或循环体中,使程序从循环体和switch语句内跳出,继续执行逻辑上的下一条语句,break语句不宜用在别处。

