標題:
陣列 (一)
[打印本頁]
作者:
tonyh
時間:
2019-7-13 16:58
標題:
陣列 (一)
分別運用四種不同的陣列宣告方式, 完成參考執行畫面.
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();
}
}
複製代碼
作者:
陳智鈞
時間:
2019-7-13 17:21
public class Ch01
{
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";
for(int i=0; i<4; i++)
System.out.print(a[i]+" ");
System.out.println();
for(int i=0; i<4; i++)
System.out.print(b[i]+" ");
System.out.println();
for(int i:c)
System.out.print(i+" ");
System.out.println();
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
蔡依宸
時間:
2019-7-13 17:26
public class World {
public static void main(String[] args) {
// TODO 自動產生的方法 Stub
String a[]={"春","夏","秋","冬"};
String b[]={"甲","乙","丙","丁"};
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();
}
}
複製代碼
作者:
章幼莛
時間:
2019-7-13 17:27
本帖最後由 章幼莛 於 2019-7-13 17:30 編輯
public class Ch01 {
public static void main(String[] args) {
String a[]={"春","夏","秋","冬"};
System.out.print("陣列a:");
for(int i=0;i<=3;i++)
{
System.out.print(a[i]+" ");
}
System.out.println();
String b[]=new String[]{"甲","乙","丙","丁"};
System.out.print("陣列b:");
for(int i=0;i<=3;i++)
{
System.out.print(b[i]+" ");
}
System.out.println();
int c[];
c=new int[]{1,2,3,4};
System.out.print("陣列c:");
for(int i:c)
{
System.out.print(i+" ");
}
System.out.println();
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
System.out.print("陣列d:");
for(String s:d)
{
System.out.print(s+" ");
}
System.out.println();
}
}
複製代碼
作者:
蔡季庭
時間:
2019-7-13 17:30
public class Ha {
public static void main(String pigs[])
{
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();
}
}
複製代碼
作者:
陳柏霖
時間:
2019-7-13 17:32
public class World {
public static void main(String[] args) {
// TODO 自動產生的方法 Stub
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 x:d)
System.out.print(x+" ");
}
}
複製代碼
作者:
洪子涵
時間:
2019-8-9 16:51
public class Ch01 {
public static void main(String[] args) {
String a[]={"春","夏","秋","冬"};
System.out.print("陣列a=");
for(int i=0;i<=3;i++)
System.out.print(a[i]+" ");
System.out.println();
String b[]=new String[]{"甲","乙","丙","丁"};
System.out.print("陣列b=");
for(int i=0;i<=3;i++)
System.out.print(b[i]+" ");
System.out.println();
int c[];
c=new int[]{1,2,3,4};
System.out.print("陣列c=");
for(int i:c)
System.out.print(i+" ");
System.out.println();
String d[]=new String[4];
d[0]="A";
d[1]="B";
d[2]="C";
d[3]="D";
System.out.print("陣列d=");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
洪藜芸
時間:
2019-8-9 16:59
public class Ci {
public static void main(String[] args) {
// TODO 自動產生的方法 Stub
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 i:d)
{
System.out.print(i+" ");
}
System.out.println();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2