One-dimensional array declaration method:type var[] or type[] Var, such as int a[], int[] A;
declaring an array in Java cannot specify its length, such as int a[5] is illegal.
creation of one-dimensional array objects: use New in Java to create an array object. The format is: var = new Type[length];
such as: int[] s; s = new int[5];. That is, a member variable S is declared in the stack space, and an array object of length 5 is created in the heap space.
Use S to point to this object. And the object is automatically initialized according to the type in the heap space, such as the initial deposit of 5 0 in S.
If the array element type is not eight basic types, it is a reference type.
Then each element in an array of reference types needs to be instantiated.
For example, suppose a date class is defined. and creates an array of the date class, constructed by date (Int,int,int): date[] D = new date[3];
Then each date[i] needs to be instantiated. D[0] = new Date (2018,7,8);
D[1] = new Date (2018,7,9);
d[2] = new Date (2017,7,10);
The array length can be var.length. Where length is a property, not a method. So no parentheses are added.
Initialization of two-dimensional arrays:should go from left to right. such as int a[][] = new int[3][]; but int a[][] = new int[][3] is illegal.
Static initialization of two-dimensional arrays, cannot specify length:
int a[][]={{},{2,3},{3,4}} is legal. but int a[3][2]={{},{2,3},{3,4}} is illegal.
Dynamic initialization of two-dimensional arrays:
int a[][] = new INT[3][5];
int b[][] = new int[3][];b[0] = new INT[2]; B[1] = new INT[3]; B[2] = new INT[5];
Sunmmervocation_learning--java Creation of arrays