返回列表 發帖

continue, break, return (三)

在程式中遇到 return 敘述, 會立即跳出所在函式.
  1. public class Ch28
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         for(int i=1; i<=10; i++)
  6.         {
  7.              if(i==5)
  8.                  return;
  9.              System.out.println(i);
  10.         }
  11.         for(int i=1; i<=10; i++)
  12.         {
  13.              System.out.println(i);
  14.         }
  15.     }
  16. }
複製代碼

  1. public class Ci {

  2.         public static void main(String[] args) {
  3.                 // TODO 自動產生的方法 Stub
  4.                 for(int i=1;i<=10;i++)
  5.                 {
  6.                         if(i==5)
  7.                                 return;
  8.                         System.out.println(i);
  9.                 }
  10.                 for(int i=1;i<=10;i++)
  11.                 {
  12.                         System.out.println(i);
  13.                 }
  14.                

  15.         }

  16. }
複製代碼

TOP

  1. public class Ch01 {

  2.         public static void main(String[] args) {
  3.                 for(int i=1;i<=10;i++)
  4.                 {
  5.                         if(i==5)
  6.                                 return;
  7.                         System.out.println(i);
  8.                 }
  9.                 for(int i=1;i<=10;i++)
  10.                 {
  11.                         System.out.println(i);
  12.                 }
  13.         }

  14. }
複製代碼

TOP

  1. public class World {

  2.         public static void main(String[] args) {
  3.                 // TODO 自動產生的方法 Stub

  4.                 for(int i=1; i<=10; i++)
  5.                 {
  6.                         if(i==5)
  7.                                 return;
  8.                         System.out.println(i);
  9.                 }
  10.                 for(int j=1; j<=10; j++)
  11.                 {
  12.                         System.out.println(j);
  13.                 }
  14.         }

  15. }
複製代碼

TOP

  1. public class Ch01 {

  2.         public static void main(String[] args) {
  3.                 for(int i=1;i<=10;i++)
  4.         {
  5.                         if(i==5)
  6.                                 return;
  7.             System.out.println(i);
  8.         }
  9.                 for(int i=1;i<=10;i++)
  10.                 {
  11.                         System.out.println(i);
  12.                 }
  13.                
  14.         }

  15. }
複製代碼

TOP

  1. public class jvav01 {

  2.         public static void main(String[] args) {
  3.                 // TODO 自動產生的方法 Stub

  4.                 for (int i = 1; i <= 10; i++) {
  5.                         if (i== 5)
  6.                                 return;
  7.                         System.out.println(i);

  8.                 }
  9.                 for (int i = 1; i <= 10; i++)
  10.                         System.out.println(i);
  11.                        
  12.         }
  13. }
複製代碼

TOP

  1. public class work {

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

TOP

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

TOP

  1. public class CH76 {

  2.         public static void main(String[] args) {
  3.                 // TODO 自動產生的方法 Stub
  4.         for(int i=1; i<=10; i++)
  5.         {
  6.                 if(i==5)
  7.                         return;
  8.                 System.out.println(i);
  9.         }
  10.         for(int i=1; i<=10; i++)
  11.         {
  12.                 System.out.println(i);
  13.         }
  14.         }
  15. }
複製代碼

TOP

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

TOP

  1. package haha;

  2. public class haha
  3. {
  4.         public static void main(String[] args)
  5.     {
  6.            for(int i=1; i<10; i++)
  7.            {
  8.                    if(i==5)
  9.                            return;
  10.                    System.out.println(i);
  11.            }
  12.            for(int i=1; i<=10; i++)                  
  13.            {
  14.                System.out.println(i);   
  15.            }
  16.         }
  17. }
複製代碼

TOP

  1. public class Class {

  2.         public static void main(String[] args) {
  3.                 // TODO 自動產生的方法 Stub
  4.              for(int i=1;i<=10;i++)
  5.              {
  6.                      if(i==5)
  7.                      {
  8.                              return;
  9.                      }
  10.                      System.out.println(i);
  11.              }
  12.              for(int i=1;i<=10;i++)
  13.              {
  14.                      System.out.println(i);
  15.              }
  16.         }

  17. }
複製代碼

TOP

返回列表