整理一些Arrays类的一些常用方法
Arrays.binarySearch()
Arrays.equals()
Arrays.copyOf()
public static void main(String[] args) {
int[] arr = new int[]{11, 22, 33, 44, 55, 66, 77,88,99};
int[] tryarray = Arrays.copyOf(arr, arr.length);
System.out.println(Arrays.toString(tryarray));
System.out.println(tryarray);
System.out.println(arr);
}
Arrays.copyOf()
Arrays.sort()
public static void main(String[] args) {
int[] a1 = {1, 3, 9, 7, 17, 13, 5, 11};
int[] a2 = {2, 10, 8, 4, 6};
System.out.println(Arrays.toString(getArrayConfusion(a1, a2)));
}
private static int[] getArrayConfusion(int[] arr1, int[] arr2) {
int[] finArray = new int[arr1.length + arr2.length];
for (int i = 0; i < arr1.length; i++) {
finArray[i] = arr1[i];
}
System.arraycopy(arr2, 0, finArray, 0 + arr1.length, arr2.length);
Arrays.sort(finArray);
return finArray;
}