1.關於數組聲明。
int a[]; //等同於int []a;
a[] = new int[100];
int a[] = new int [100];
2.數組初始化。
int k[] = {1,2,3}; //這裏是大括號
int k[] = new int[]{1,2,3,4};
3.數組拷貝。
直接拷貝。
使用clone()方法。
例如:int a[] = array.clone();
使用System.arraycopy()
System.arraycopy(int from,int fromIndex,int to,int toIndex,int count)
// 將數組from中的索引爲fromIndex開始的元素拷貝到數組to中索引爲toIndex的位置,總共拷貝的元素個數爲count個。
4.二維數組。
int [][] array;
int [][] array = new int[10][]; //只聲明一個維度的大小,另一個使用的時候再說。
array[0]= new int[5]; //第一行爲5列
int [][]array = {
{1,2}
{3,4,5,6}
}