1. Declaring and allocating memory for one-dimensional arrays
Array type array name [] = NULL//declaration one-dimensional array
Array name = new array type [length]//Allocate memory to array
Array type [] array name = NULL//declaration one-dimensional array
Data type array name [] = new data type [NUMBER]//Declare array while allocating memory
2. Get the length of the array
Array name. Length--Returns an int type of data
3. Complete array sorting using Java class Library
Java.util.Arrays.sort (array name)
4. Copying of arrays in Java
The copy operation of the Java array can be divided into deep copy and shallow copy, simple deep copy, can copy the object's value and object's content; Shallow copy refers to the copy of the object reference.
You can use System.Array () to copy an array.
For a one-dimensional array, this copy property value is passed and the modified copy does not affect the original value. When an object is stored in a two-dimensional or one-dimensional array, the copy result is one-dimensional reference variable passed to the copy of the one-dimensional array, and when the copy is modified, the original array is affected.
The function prototypes for system.arraycopy are:
public static void Arraycopy (Object src, int srcpos,object dest,int destpos,int length)
Where: src represents the source array, Srcpos represents the starting position where the source array is to be copied, DESC represents the destination array, Destpos represents the starting position of the destination array to be copied, and length indicates how long to copy.
5, JAVA----variable parameters
Definition format for variable parameters
Return value type method name (Type ... Parameter name) {}
6. JAVA----foreach Output
Mainly for the convenience of array output
For (data type variable name: array name) {
........
}
Fourth chapter arrays and methods