標題:
陣列 (一)
[打印本頁]
作者:
陳品肇
時間:
2019-7-4 10:45
標題:
陣列 (一)
分別運用四種不同的陣列宣告方式, 完成參考執行畫面.
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-4 11:25
package text369;
public class text123 {
public static void main(String[] args) {
int a[]={1,2,3,4};
String c[]={"OSDFPOS","AJFILO","DFAFV"};
int jkad[]=new int[2];
jkad[0]=3;
jkad[1]=4;
for(int i:a)
{
System.out.println(i);
}
int grgs[];
grgs=new int[]{1,5,6,7};
String joia[]=new String[]{"lkgan","jgreg0","d","sht"};
}
}
複製代碼
作者:
湯東緯
時間:
2019-7-4 11:26
import java.util.Scanner;
public class Ch01 {
public static void main(String arg[]) {
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.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();
}
}
複製代碼
作者:
黃安立
時間:
2019-7-4 11:27
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-4 11:30
public class junior01 {
public static void main(String args[]){
String a[]=new String[]{"春","夏","秋","冬"};
String ab[]=new String[]{"甲","乙","丙","丁"};
int c[]=new int[]{1,2,3,4};
String ac[]=new String[]{"A","B","C","D"};
System.out.print("陣列a:");
for (int i = 0;i<=3;i+=1)
System.out.print(a[i]);
System.out.println();
System.out.print("陣列ab:");
for (int i = 0;i<=3;i+=1)
System.out.print(ab[i]);
System.out.println();
System.out.print("陣列c:");
for (int i = 0;i<=3;i+=1)
System.out.print(c[i]);
System.out.println();
System.out.print("陣列ac:");
for (int i = 0;i<=3;i+=1)
System.out.print(ac[i]);
}
}
複製代碼
作者:
呂昀宸
時間:
2019-7-4 11:33
public class nsezz {
public static void main(String[] args) {
String a[] = { "春", "夏", "秋", "冬" };
String b[] = new String[] { "甲", "乙", "丙", "丁" };
String c[] = new String[4];
c[0] = "A";
c[1] = "b";
c[2] = "C";
c[3] = "D";
int d[];
d = new int[] { 1, 2, 3, 4 };
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 (String i : c)
System.out.print(i + " ");
System.out.println();
System.out.println("陣列d: ");
for (int i : d)
System.out.print(i + " ");
System.out.println();
}
}
複製代碼
作者:
黃恆嘉
時間:
2019-7-4 11:38
public class Ch06 {
public static void main(String args[]) {
String a[] = { "春", "夏", "秋", "冬" };
System.out.print("陣列a: ");
for (int i = 0; i < 4; i++)
System.out.print(a[i] + " ");
System.out.println();
String b[] = new String[] { "甲", "乙", "丙", "丁" };
System.out.print("陣列b: ");
for (int i = 0; i < 4; 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-4 11:39
public class Ch09 {
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