返回列表 發帖
  1. public class Ch01
  2. {
  3.         public static void main(String args[])
  4.         {
  5.        
  6.                 String a[]={"春","夏","秋","冬"};
  7.                
  8.                 String b[]=new String[]{"甲","乙","丙","丁" };
  9.                
  10.                 int c[];
  11.                 c=new int[]{1,2,3,4};
  12.                
  13.                 String d[]=new String[4];
  14.                 d[0]="A";
  15.                 d[1]="B";
  16.                 d[2]="C";               
  17.                 d[3]="D";
  18.                
  19.                 System.out.print("陣列a: ");
  20.                 for(int i=0; i<4; i++)
  21.                         System.out.print(a[i]+" ");
  22.                 System.out.println();
  23.                
  24.                 System.out.print("陣列b: ");
  25.                 for(int i=0; i<4; i++)
  26.                         System.out.print(b[i]+" ");
  27.                 System.out.println();
  28.                
  29.                 System.out.print("陣列c: ");
  30.                 for(int i:c)
  31.                         System.out.print(i+" ");
  32.                 System.out.println();
  33.                
  34.                 System.out.print("陣列d: ");
  35.                 for(String s:d)
  36.                         System.out.print(s+" ");
  37.                 System.out.println();
  38.                
  39.                        
  40.                
  41.                
  42.                
  43.         }
  44.                                        
  45.                        
  46.        
  47. }
複製代碼

TOP

返回列表