package com.leo;
import java.util.Arrays;
public class ArraysTest {
public static void main(String[] args) {
int[] arr1 = new int[]{1, 2, 3, 4};
int[] arr2 = new int[]{1, 3, 2, 4};
// 判断两个数组是否相等
boolean isEquals = Arrays.equals(arr1, arr2);
System.out.println(isEquals);
// 输出数组信息
System.out.println(Arrays.toString(arr1));
// 将指定值填充到数组中
Arrays.fill(arr1, 10);
System.out.println(Arrays.toString(arr1));
// 对数组进行排序
Arrays.sort(arr2);
System.out.println(Arrays.toString(arr2));
// 二分查找
int[] arr3 = new int[]{-98, -34, 2, 34, 54, 66, 79, 321};
int index = Arrays.binarySearch(arr3, 2);
if (index >= 0) {
System.out.println(index);
} else {
System.out.println("未找到");
}
}
}