標題:
陣列 (一)
[打印本頁]
作者:
tonyh
時間:
2016-5-6 21:15
標題:
陣列 (一)
本帖最後由 tonyh 於 2017-11-25 15:14 編輯
分別運用三種不同的陣列宣告方式, 完成參考執行畫面.
[attach]1603[/attach]
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(String i:c)
System.out.print(i+" ");
System.out.println();
}
}
複製代碼
作者:
洪振庭
時間:
2016-5-6 21:21
public class Ch35
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
String c[]
c={"東","西","南","北"};
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();
}
}
複製代碼
作者:
沈子耕
時間:
2016-5-6 21:24
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();
}
}
複製代碼
作者:
梁和雋
時間:
2016-5-6 21:25
public class Ch30
{
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();
}
}
複製代碼
作者:
陳思惟
時間:
2016-5-6 21:26
public class Ch38
{
public static void main(String args[])
{
String a[]={"A","B","C","D"};
String b[]=new String[]{"1","2","3","4"};
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();
}
}
複製代碼
作者:
黃柏維
時間:
2016-5-6 21:27
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();
}
}
複製代碼
作者:
曾挺桂
時間:
2016-5-6 21:31
public class Ch34
{
public static void main(String args[])
{
String a[]={"A","B","C","D"};
String b[]=new String{"E","F","G","H"};
String c[];
c=new String[]{"I","J","K","L"};
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 j=0; j<4; j++)
System.out.print(b[j]+" ");
System.out.println();
System.out.print("陣列c: ");
for(int k=0; k<4; k++)
System.out.print(c[k]+" ");
System.out.println();
}
}
複製代碼
作者:
李知易
時間:
2016-5-6 21:36
[code][/code]
作者:
李知易
時間:
2016-5-6 21:36
public class Ch37
{
public static void main(String args[])
{
String a[]={"UP","DOWN","LEFT","RIGHT"};
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();
}
}
複製代碼
作者:
王翔
時間:
2016-5-7 16:27
public class Ch30
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
String c[]=new String[]{"東","西","南","北"};
System.out.println("陣列A: ");
for(int i=0;i<4;i++)
System.out.println(a[i]+" ");
System.out.println();
System.out.println("陣列B: ");
for(int i=0;i<4;i++)
System.out.println(b[i]+" ");
System.out.println();
System.out.println("陣列C: ");
for(int i=0;i<4;i++)
System.out.println(c[i]+" ");
System.out.println();
}
}
複製代碼
作者:
黃璽安
時間:
2016-5-8 13:58
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();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2