4.5 Array type
An array is also a type. It is itself a reference type. For example, int is a basic type, int[] is a reference type.
Two ways to define an array:
1.type[] Arrayname;
2.type arrayname[];
The first one is usually recommended, which is both easy to understand and conforms to the syntax for defining variables.
If the index value specified when accessing an array element is less than 0, or greater than or equal to the length of the array, the compiler will not have any errors, but the runtime throws an exception
4.5.5foreach Cycle
String[] books={"Kingdoms", "Journey to the Monkey", "Red Mansions"}; for (String book:books) { System.out.println (book);}
But one thing, when using foreach to iterate over an algebraic group element, the loop variable in foreach is equivalent to a temporary variable, and the system assigns the array element to the temporary variable at once, which is not an array element, it only holds the value of the array element, so if you want to change the value of the array element, You cannot use the Foreach loop.
4.6 In-depth arrays
Crazy java--Fourth chapter flow control and array