標題:
陣列 (一)
[打印本頁]
作者:
tonyh
時間:
2017-2-25 11:34
標題:
陣列 (一)
本帖最後由 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();
}
}
複製代碼
作者:
黃茂勛
時間:
2017-2-25 11:52
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]+" ");
}
}
複製代碼
作者:
陸長辰
時間:
2017-2-25 11:53
public class Ch26
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]={"甲","乙","丙","丁"};
String 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]+" ");
}
}
複製代碼
作者:
陳泓瑜
時間:
2017-2-25 11:55
public class Ch28
{
public static void main(String args[])
{
String a[]=new String[]{"A","B","C","D"};
String b[]=new String[]{"A","B","C","D"};
String c[]=new String[]{"A","B","C","D"};
System.out.println("陣列A:");
for(int i=0; i<4; i++)
{
System.out.println(a[i]);
}
System.out.println("陣列B:");
for(int i=0; i<4; i++)
{
System.out.println(b[i]);
}
System.out.println("陣列C:");
for(int i=0; i<4; i++)
{
System.out.println(c[i]);
}
}
}
複製代碼
作者:
林侑成
時間:
2017-2-25 11:57
public class Edit1
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"a","b","c","d"};
String c[];
c[]=new String[]{"n","e","s","w"};
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://seed.istak.org.tw/)
Powered by Discuz! 7.2