General Write SyStem.out.pirntln (xxxxx); This is the default line break equals after printing by default added:/n/r, if you want to output on the same line, then write: system.out.print (xxx);
Defined:
int a[]; Declaration not initialized
A = new int [10]; Define the size of the footprint (10 Int)
int a[] = new int [10]; Declare and define size (that is, space assigned the specified Size)
int a[] = {n/a}; Declares and initializes, with a space size of 3 int.
Initialization
One-dimensional arrays
1)
int[] a; declaration, not initialized
2)
int[] a=new int[5];
3)
int[] a={1,2,3,4,5};
Initialize to the given value
4)
int[] a=new int[]{1,2,3,4,5};
int[] a=new int[5]{1,2,3,4,5};
error, cannot define a dimension expression if an array initialization operation is provided
5)
int[] a;
A=new int[5]; right, Same as (2)
int[] a;
a={1,2,3,4,5}; Error array constants can only be used in initialization operations, such as (3)
6)
a[0]=1;
Error because the array is not initialized and cannot be assigned a value of a[1]=2; Two-dimensional arrays
1)
declaration, not initialized
2) int[][] a=new int[2][3];
3)
int[][] a={{1,2},{2,3},{3,4}};
Initialize to the given value
int[][] a={{1,2},{2,3},{3,4,5}};
No mistake, The array space is not contiguous, so the size of each dimension is not required
4)
The size of each dimension can be different
5)
int[][] a=new
int[][]{{1,2},{2,3},{3,4,5}};
Same (3)
Java array Definition and initialization of +print printing problems