Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BreakContinueDemo {
- public static void main(String[] args){
- /*
- * breakt跳出
- * break作用的范围,要么是switch语句,要么是循环语句
- * 当break语句存在时,下面不要定义其他语句,因为执行不到
- *如果出现循环嵌套,可以通过标号跳出循环
- * 跳出指定的标签,就意味着只能在循环区间
- * 在区间外面,则break语句失效!*/
- xiaoqiang:for (int x = 0;x<3;x++){
- wangcai:for (int y = 0;y<5 ;y++){
- System.out.println("x="+x);
- //break xiaoqiang;
- }
- break xiaoqiang;
- //break要是在这里 以下的语句永远无法执行
- //System.out.println("x = "+x);
- }
- }
- }
Add Comment
Please, Sign In to add comment