標題:
陣列 (一)
[打印本頁]
作者:
tonyh
時間:
2020-2-4 11:06
標題:
陣列 (一)
分別運用四種不同的陣列宣告方式, 完成參考執行畫面.
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();
}
}
複製代碼
作者:
張宸翔
時間:
2020-2-4 11:30
import java.util.Scanner;
public class Ch01 {
public static void main(String[] args) {
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();
}
}
複製代碼
作者:
黃煜城
時間:
2020-2-4 11:31
public class Ch20 //112~118
{
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();
}
}
複製代碼
作者:
盧弘毅
時間:
2020-2-4 11:32
public class Ch50
{
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();
}
}
複製代碼
作者:
蔡承翰
時間:
2020-2-4 11:32
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";
System.out.println("陣列A: ");
for(int i=0;i<4;i++)
System.out.print(a[i]+" ");
System.out.println();
System.out.println("陣列B: ");
for(int i=0;i<4;i++)
System.out.print(b[i]+" ");
System.out.println();
System.out.println("陣列C: ");
for(int i:c)
System.out.print(i+" ");
System.out.println();
System.out.println("陣列D: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
蘇宜貞
時間:
2020-2-4 11:32
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";
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();
}
}
複製代碼
作者:
蘇行一
時間:
2020-2-4 11:33
import java.util.Scanner;
public class Ch1 {
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();
}
}
複製代碼
作者:
楊秉樺
時間:
2020-2-4 11:34
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 i:d)
System.out.print(i+"");
System.out.println();
}
}
複製代碼
作者:
劉家銘
時間:
2020-2-4 11:36
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.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();
System.out.println("陣列d: ");
for(String s:d)
System.out.println(s+" ");
System.out.println();
}
}
複製代碼
作者:
邱翊博
時間:
2020-2-4 11:36
package abc;
public class abc {
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();
}
}
複製代碼
作者:
何蕙妘
時間:
2020-2-4 11:37
public class Ch55 extends Ch54 {
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();
}
}
複製代碼
作者:
沙芃妘
時間:
2020-2-4 11:42
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.println("陣列a:");
for(int i=0; i<4; i++)
System.out.print(a[i]+" ");
System.out.println();
System.out.println("陣列b:");
for(int i=0; i<4; i++)
System.out.print(b[i]+" ");
System.out.println();
System.out.println("陣列c:");
for(int i:c)
System.out.print(i+" ");
System.out.println();
System.out.println("陣列d:");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2