本帖最後由 tonyh 於 2014-11-29 17:03 編輯
試用6種不同的陣列宣告方式, 宣告包括春夏秋冬四個成員的陣列.- public class ch35
- {
- public static void main(String args[])
- {
- String a[]={"春","夏","秋","冬"};
- String[] b={"春","夏","秋","冬"};
- String c[]=new String[]{"春","夏","秋","冬"};
- String[] d=new String[]{"春","夏","秋","冬"};
- String e[];
- e=new String[]{"春","夏","秋","冬"};
- String[] f;
- f=new String[]{"春","夏","秋","冬"};
- System.out.println("陣列a: "+a[0]+a[1]+a[2]+a[3]);
- System.out.println("陣列b: "+b[0]+b[1]+b[2]+b[3]);
- System.out.println("陣列c: "+c[0]+c[1]+c[2]+c[3]);
- System.out.println("陣列d: "+d[0]+d[1]+d[2]+d[3]);
- System.out.println("陣列e: "+e[0]+e[1]+e[2]+e[3]);
- System.out.println("陣列f: "+f[0]+f[1]+f[2]+f[3]);
- }
- }
複製代碼 |