本帖最後由 tonyh 於 2017-2-25 11:45 編輯
分別運用三種不同的陣列宣告方式, 完成參考執行畫面.
 - public class Ch34
- {
- public static void main(String args[])
- {
- String a[]={"春","夏","秋","冬"};
-
- String b[]=new String[]{"甲","乙","丙","丁"};
- String c[];
- c=new String[]{"東","南","西","北"};
- System.out.print("陣列a: ");
- for(int i=0; i<4; i++)
- System.out.print(a[i]+" ");
- System.out.println();
- System.out.print("陣列b: ");
- for(int i=0; i<4; i++)
- System.out.print(b[i]+" ");
- System.out.println();
-
- System.out.print("陣列c: ");
- for(int i=0; i<4; i++)
- System.out.print(c[i]+" ");
- System.out.println();
- }
- }
複製代碼 |