public class BCLoop
     {
          public static void main(String[] args)
         {
             int i=0;
             while (i++<100){
                 System.out.println("Looping with i.");
                 break;
                 System.out.println("Please don't print me!");
             }
             int j=0;
             while (j++<100){
                 System.out.println("Looping with j!");
                 continue;
                 System.out.println("Please don't print me!");
              }
         }
    }
探讨一下,break:continue;后的语句会不会执行。

解决方案 »

  1.   

    这有什么好讨论的,你的break和contiune后面的两条语句永远不可达
    程序是不可以这么写的
      

  2.   

    break跳出循环continue继续break和continue后的打印语句无法到达
      

  3.   

    是啊,我也纳闷,这可是教程上的啊.真是“尽信书不如无书。”
    http://202.116.65.197/wlkc/java/chapter3/section3_3/page3_3_2.htm
      

  4.   

    break跳出全部循环continue跳出本次循环,继续下一次循环上面程序中应该是Looping with i.打印1遍Looping with j!打印100遍