Array: Is the space to store the same type of data in memory continuously
Because you need to store large amounts of data of the same type in real-world applications, you have an array
Definition of array: data type [] array name =new data type [length];
Example: int [] a = new int [10];
data type [] array name =new data type []{value, separated by commas};
Example: int [] b = new int []{1,2,3,4,5};
Array assignment and value: use subscript to manipulate each element in the array
Assignment: array name [subscript] = value;
Value: array name [subscript];
Note: The index of an element in an array starts at 0, and the maximum subscript value is less than the length of the array 1
The benefits of arrays:
1. Define multiple spaces for storing data at once
2. Can be used in conjunction with a For loop, using the loop variable as the subscript for the data
One-dimensional arrays:
①int [] n = new int [5]; N[0] = 1; N[1] = 2; n[2] = 3; n[3] = 4; N[4] = 5;
②int[] n = new int[] {1,2,3,4,5};
Two-dimensional array: int[,] a =new int [4,2];
15-07-08 Array