循环跳转语句 : 
    break [label]  //用来从语句、循环语句中跳出。
    continue [label]  //跳过循环体的剩余语句,开始下一次循环。
    这两个语句都可以带标签(label)使用,也可以不带标签使用。标签是出现在一个语句之前的标识符,标签后面要跟上一个冒号(:),标签的定义如下:
    label:statement;
    实践:
    1、  break语句
| class Break { public static void main(String args[]) { boolean t = true. first: { second: { third: { System.out.println("Before the break."). if(t) break second. // break out of second block System.out.println("This won t execute"). } System.out.println("This won t execute"). } System.out.println("This is after second block."). } } }  | 
    // 跳出循环
| class BreakLoop { public static void main(String args[]) { for(int i=0. i<100. i  ) { if(i = = 10) break. // terminate loop if i is 10 System.out.println("i: "   i). } System.out.println("Loop complete."). } }  | 
    //跳出switch
| class SampleSwitch { public static void main(String args[]) { for(int i=0. i<6. i  ) switch(i) { case 0: System.out.println("i is zero."). break. case 1: System.out.println("i is one."). break. case 2: System.out.println("i is two."). break. case 3: System.out.println("i is three."). break. default: System.out.println("i is greater than 3."). } } }  | 
 
这个在昨天的分支语句中,我们就已经学到了。
    2、  continue语句
| class Continue { public static void main(String args[]) { for(int i=0. i<10. i  ) { System.out.print(i   " "). if (i%2 = = 0)  continue. System.out.println(""). } } }  | 
    //带标签的continue
| class ContinueLabel { public static void main(String args[]) { outer: for (int i=0. i<10. i  ) { for(int j=0. j<10. j  ) { if(j > i) { System.out.println(). continue outer. } System.out.print(" "   (i * j)). } } System.out.println(). } }  | 
 
 
								 
									
相关文章
									
java初学者实践教程11-泛型声明
java初学者实践教程10-集合类
java初学者实践教程9-数组
java初学者实践教程8—jdk5的拆箱与装箱
java初学者实践教程7-跳转语句
人民大学研究生导师招生不再“平均主义”
2008年外校推荐免试生申请攻读人大硕士生办法
读研不是高消费08年考研招生院校收费大比拼
北京大学2008年研招保送生名额超半惹发争议
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛