返回列表 發帖

continue, break, return (一)

本帖最後由 tonyh 於 2016-4-29 20:31 編輯

continue 語法能強制程序立即跳入下一輪迴圈.
  1. public class Ch26
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼

  1. public class Ch30
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class Ch29
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class Ch26
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class Ch23
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class Ch26
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼
http://fs-old.mis.kuas.edu.tw/~s1102137106/music/

TOP

  1. public class Ch32
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class Ch26
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼
ABCDEFGHIJKLMNOPQRSTUVWXYZ

TOP

  1. public class Ch26
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼

TOP

  1. public class Ch26
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i%2==0)
  8.                  continue;
  9.              System.out.println(i);
  10.         }
  11.     }
  12. }
複製代碼

TOP

返回列表