定義愕提,java的數(shù)組是引用類型
- 相同數(shù)據(jù)類型的連續(xù)的數(shù)據(jù)空間
1.動態(tài)初始化
int[] a = new int[3];
//二維數(shù)組
int [][] aa = new int[2][];
aa[0] = new int[2];
aa[1] = new int[2];//當(dāng)然也可以不規(guī)整
等價于:
int aaa = new int [2][2];
2.靜態(tài)初始化
int [] b= {1,2,3}; //相當(dāng)于
int [] b = new int[3];
b[0] = 1;
b[1] = 2;
b[2] = 3//的簡寫版
//二維數(shù)組
int [][] bb = {{1,2,3},{1,2,3,4}};