一,數組聲明
語法: 數據類型[ ] 數組名;
或者 數據類型 數組名[ ];
注:數據類型可爲:整型,浮點型,字符串型
例子:int[] scores;
int scores[] ;//這一種和c一樣
二,分配空間
語法: 數組名 = new 數據類型 [ 數組長度 ];
例子:scores=new scores[10];//長度爲10的整型數組
注意:在聲明數組的同時爲它分配空間,如:int [] scores=new int[10];
三,賦值
int[] scores={89,123,123,435};
等價於 int[] scores-new int[]{89,123,123,435};//第二個[]必須爲空,不能指定長度