標題:
陣列 (一)
[打印本頁]
作者:
tonyh
時間:
2019-8-6 11:08
標題:
陣列 (一)
分別運用四種不同的陣列宣告方式, 完成參考執行畫面.
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-8-6 11:37
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-8-6 11:38
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-8-6 11:39
public class Ch10
{
public static void main(String args[])
{
String x[]={"春","夏","秋","冬"};
System.out.print("陣列一: ");
for(int i=0; i<4; i++)
System.out.print(x[i]+" ");
System.out.println();
String y[]=new String[]{"甲","乙","丙","丁"};
System.out.print("陣列二: ");
for(int i=0; i<4; i++)
System.out.print(y[i]+" ");
System.out.println();
int m[];
m=new int[]{1,2,3,4};
System.out.print("陣列三: ");
for(int i:m)
System.out.print(i+" ");
System.out.println();
String n[]=new String[4];
n[0]="A";
n[1]="B";
n[2]="C";
n[3]="D";
System.out.print("陣列四: ");
for(String s:n)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
張書涵
時間:
2019-8-6 11:40
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.print("\n陣列b: ");
for(int i=0; i<4; i++)
System.out.print(b[i]+" ");
System.out.print("\n陣列c: ");
for(int i:c)
System.out.print(i+" ");
System.out.print("\n陣列d: ");
for(String s:d)
System.out.print(s+" ");
System.out.println();
}
}
複製代碼
作者:
余映均
時間:
2019-8-6 11:41
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-8-6 11:42
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-8-6 11:42
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-8-6 11:43
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 i:d)
System.out.print(i+" ");
}
}
複製代碼
作者:
鄭宇崴
時間:
2019-8-6 11:43
public class Ch10
{
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-8-6 11:43
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.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-8-6 11:44
import java.util.Scanner;
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-8-6 11:44
import java.util.Scanner;
public class Ch11
{
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 i:d)
System.out.print(i+"")
;System.out.println();
}
}
複製代碼
作者:
何育翔
時間:
2019-8-6 11:45
public class Ch23
{
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-8-6 11:46
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-8-6 11:50
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-8-6 11:52
public class Ch10
{
public static void main(String args[])
{
String a[]={"春","夏","秋","冬"};
String b[]=new String[]{"甲","乙","丙","丁"};
int c[]={1,2,3,4};
String d[]=new String[]{"A","B","C","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();
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2