First, array-related
1. Variable parameters
When designing a method, the number of the last parameter of the method is variable, and the parameter of the change is called the variable parameter
New features added by jdk1.5, for cases where the number of parameters is ambiguous and the type is determined
Variable parameters are treated as arrays in Java
Precautions:
1. The variable parameter must be the last item in the formal parameter list
2, three points ... Between the variable type and the variable name, there are no spaces before or after it is possible.
2. Arrays Tool Class
Responsible for sorting, finding, and so on the array
Primarily for manipulating one-dimensional arrays
Java.util.Arrays
static method: Use the class name. Method name to call directly
Common methods:
1. Convert array sort contents to string output
String arrays.tostring (int[] array)
2. Array sort default Ascending
void Arrays.sort (int[] array)
3. Use binary Check table method: Gets the index of the specified element from the array
Return with no return negative
int Arrays.binarysearch (int[] array,int value)
4. Copy the specified array
4.1 int[] arrays.copyof (int[] array,int newlength)
Contains length number of lengths
4.2 int[] Arrays.copyofrange (int[] array,int from,int to)
The angle mark contains the head does not contain the tail [from,to]
5. Determine whether two arrays are equal
Boolean arrays.equals (int[] array1,int[] array2)
6. Populating an array with the specified elements
void Arrays.fill (int[] array, populated data)
3. Two-dimensional array
Concept:
Each element type in the array is a one-dimensional array
Example:
Defined:
Java Basics-Arrays and object-oriented