import java.util.*;
/*
Arrays.
toString
sort
binarySearch
copyOf
equals
*/
public class ArraysTest1 {
public static void main(String[] args) {
int[] arr = {90,-1,-100,10,20,30};
System.out.println(Arrays.toString(arr));
//排序
Arrays.sort(arr);
System.out.println(Arrays.toString(arr));
//二分查找 有序
int index = Arrays.binarySearch(arr, 20);
System.out.println("index = " + index);
String [] arr1 = {"安琪拉","米莱迪","妲己"};
// String[] newArr = Arrays.copyOf(arr1, arr1.length*2);
arr1 = Arrays.copyOf(arr1, arr1.length*2);
System.out.println("Arrays.toString(arr1) = " + Arrays.toString(arr1));
/*
按照范围复制
Arrays.copyOfRange(数组名, 开始下标, 结束下标);
结果 [开始下标, 结束下标)
*/
String[] strings = Arrays.copyOfRange(arr1, 0, 2);
System.out.println("Arrays.toString(strings) = " + Arrays.toString(strings));//"安琪拉","米莱迪"
int[] arr3 = new int[6];
System.out.println("Arrays.toString(arr3) = " + Arrays.toString(arr3));
//Arrays.fill(arr3, 66);
/*
按照范围填充
Arrays.fill(数组名, 开始下标, 结束下标, 填充的值);
[开始下标, 结束下标)
*/
Arrays.fill(arr3, 1, 4, 88);
System.out.println("Arrays.toString(arr3) = " + Arrays.toString(arr3));
int [] arr4 = {1,2,3};
int [] arr5 = {1,3,2};
//数组== 比较的是地址值
System.out.println(arr4==arr5);
//比较的是数组元素的内容 按照下标逐个比较
boolean flag = Arrays.equals(arr4, arr5);
System.out.println("flag = " + flag);
System.out.println(10==10);//true
}
}