標題:
陣列 (一)
[打印本頁]
作者:
tonyh
時間:
2021-9-25 19:54
標題:
陣列 (一)
分別運用四種不同的陣列宣告方式, 完成參考執行畫面.
public class Ch34
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4]; //宣告空陣列
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
王秉鈞
時間:
2021-9-25 20:10
public class Ch15
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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();
System.out.print("陣列d: ");
for(int i=0;i<4;i++)
System.out.print(d[i]+" ");
System.out.println();
}
}
複製代碼
作者:
蔡寓珉
時間:
2021-9-25 20:13
public class Ch30
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4]; //宣告空陣列
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
林鼎傑
時間:
2021-9-25 20:22
public class Ch31
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4]; //宣告空陣列
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
林土水
時間:
2021-9-25 20:25
本帖最後由 林土水 於 2021-9-25 20:50 編輯
public class Ch32
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(c[i]+" ");
System.out.println();
System.out.print("陣列d: ");
for(int i=0;i<4;i++)
System.out.print(d[i]+" ");
System.out.println();
}
}
複製代碼
作者:
林佑宸
時間:
2021-9-25 20:32
本帖最後由 林佑宸 於 2021-9-25 20:48 編輯
public class Ch34
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
俞成章
時間:
2021-9-25 20:37
public class Ch34
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
朱奕祐
時間:
2021-9-25 20:38
public class Ch34
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
余柏緯
時間:
2021-9-25 20:38
import java.lang.System;
import java.io.Console;
public class Ch37
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
{
System.out.print(i+" ");
}
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
{
System.out.print(s+" ");
}
System.out.println();
}
}
複製代碼
作者:
陳志祐
時間:
2021-9-25 20:42
public class Ch35
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
黃子倢
時間:
2021-9-25 20:43
public class Ch34
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4]; //宣告空陣列
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
許洧熏
時間:
2021-9-25 20:44
public class Ch34
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(i+" ");
System.out.println();
System.out.print("陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
王秉鈞
時間:
2021-9-25 20:50
public class Ch15
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
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:c)
System.out.print(c[i]+" ");
System.out.println();
System.out.print("陣列d: ");
for(int S:d)
System.out.print(d[i]+" ");
System.out.println();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2