I'm not targeting someone, I'm talking about all the scum here!
PackageCom.mi.array;Importjava.util.Arrays;/*** System.arraycopy (i, 0, J, 0, i.length); This copy overwrites the copy of the target array element * Array *@authorAdmin **/ Public classCopyarray { Public Static voidMain (string[] args) {int[] i =New int[7]; int[] J =New int[10]; Arrays.fill (i,47); Arrays.fill (J,99); System.out.println ("I=" +arrays.tostring (i)); System.out.println ("J=" +arrays.tostring (j)); //parameters (the original array, the starting position of the original array, the target array, the starting position of the target array, the number of elements that need to be copied)System.arraycopy (i, 0, J, 0, i.length); System.out.println ("J=" +arrays.tostring (j)); /*** Results * i= [99, 99, 99, 99, 99, 99, 99, 99, 99, 99] j= [+. j= [ +, A, a, a, a, a, ~ ~*/ }}
PackageCom.mi.array;Importjava.util.Arrays;/*** * Array comparison/array element comparison *arrays.equals condition: 1, array length equal, 2, the value of the corresponding position of the array must be equal*/ Public classComparearray { Public Static voidMain (string[] args) {int[] a1=New int[10]; int[] a2=New int[10]; //Arrays.fill can also pass values to specific intervals of an array, such as Arrays.fill (a1,2,4 47); //Similarly, arrays.sort can order specific intervals, such as arrays.sort (a1,27);Arrays.fill (A1, 47); Arrays.fill (A2,47); System.out.println (Arrays.equals (a1, a2)); }}
PackageCom.mi.array;ImportJava.util.*;/*** Array sort/Find in sorted array *@authorAdmin **/ Public classStringsort { Public Static voidMain (string[] args) {int[] a1=New int[10]; //returns the index of the value in the array, or 1 if it does not exist intIndex = Arrays.binarysearch (A1, 2); }}
Array operations in Java advanced, don't ask me why, the code interprets everything!