標題:
陣列 (一)
[打印本頁]
作者:
tonyh
時間:
2019-7-4 10:53
標題:
陣列 (一)
分別運用四種不同的陣列宣告方式, 完成參考執行畫面.
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:20
package ok;
public class foradd2
{
public static void main(String args[])
{
String a[]={"autumn","summer","fall","winter"};
String b[]=new String[]{"A","B","C","F"};
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:24
import java.util.Scanner;
public class Ch05 {
public static void main(String[] args)
{
String a[]={"Spring","Summer","Autumn","Winter"};
String b[]=new String[]{"A","B","C","D"};
int c[];
c=new int[]{1,2,3,4};
String d[]=new String[4];
d[0]="Excellent";
d[1]="Good";
d[2]="Average";
d[3]="Bad";
System.out.print("Sequnce a: ");
for(int i=0; i<4; i++)
System.out.print(a[i]+" ");
System.out.println();
System.out.print("Sequnce b: ");
for(int i=0; i<4; i++)
System.out.print(b[i]+" ");
System.out.println();
System.out.print("Sequnce c: ");
for(int i:c)
System.out.print(i+" ");
System.out.println();
System.out.print("Sequnce d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
李承洋
時間:
2019-7-4 11:26
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(i+" ");
System.out.println();
System.out.print("陣列D: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
陳致翰
時間:
2019-7-4 11:27
package Ch01;
import java.util.Scanner;
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();
}
}
複製代碼
作者:
陳柏銓
時間:
2019-7-4 11:27
public class Ch127 {
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();
}
}
複製代碼
作者:
李從赫
時間:
2019-7-4 11:27
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();
}
}
}
複製代碼
作者:
蔡杰恩
時間:
2019-7-4 11:27
public class Ch87 {
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:28
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();
}
}
複製代碼
作者:
蔡杰希
時間:
2019-7-4 11:28
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=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();
}
}
複製代碼
作者:
王煦
時間:
2019-7-4 11:28
public class Ch02
{
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();
}
}
複製代碼
作者:
李沛儒
時間:
2019-7-4 11:28
public class Ch00
{
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<=3; i++)
System.out.print(a[i]+" ");
System.out.println();
System.out.print("陣列b: ");
for(int i=0; i<=3; 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:28
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:28
public class Ch14
{
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:29
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();
}
}
複製代碼
作者:
宋威廷
時間:
2019-7-4 11:31
public class CH06
{
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:31
public class Ch333
{
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: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();
}
}
複製代碼
作者:
林宥杰
時間:
2019-7-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();
}
}
複製代碼
作者:
葉子于
時間:
2019-7-4 11:33
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.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:c)
System.out.println(i+" ");
System.out.println();
System.out.println("陣列d:");
for(String s:d)
System.out.println(s+" ");
System.out.println();
}
}
複製代碼
作者:
張啟廣
時間:
2019-7-4 11:36
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<=3; i++)
System.out.print(a[i]+" ");
System.out.println();
System.out.print("陣列b: ");
for(int i=0; i<=3; 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:38
public class ch02
{
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:46
public class ch02
{
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();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2