package test;
import java.util.Arrays;
public class ArraysAll {
public static void main(String[] args) {
int[] array1 = new int[]{9,3,5,5,6,1};
int[] array2 = new int[]{9,5,5,3,1,6};
//复制长度为数组名.length 修改也没用
Arrays.copyOf(array1, 4);
System.out.println("我的长度为4");
for (int i : array1) {
System.out.print("\t"+i);
}
Arrays.sort(array1);
Arrays.sort(array2);
System.out.print("\n");
System.out.println("升序后数为:");
for (int i : array1) {
System.out.print("\t"+i);
}
System.out.print("\n");
Arrays.copyOf(array1, 7);
System.out.println("我的长度为3");
for (int i : array1) {
System.out.print("\t"+i);
}
System.out.print("\n");
int index = Arrays.binarySearch(array1,6);
System.out.println("查找数6的下标是:\n\t"+index);
boolean flag = Arrays.equals(array1, array2);
System.out.println("比较结果是:\n\t"+flag);
//转换成字符串就为一个值了
String arr1 = Arrays.toString(array1);
System.out.println("我是string:\n\t"+arr1);
//结果为 :我是string:[1, 3, 5, 5, 6, 9]
Arrays.fill(array1, 88);
System.out.println("我是88哦:");
for (int i : array1) {
System.out.print("\t"+i);
}
}
}