package oj.test;
import java.util.*;
public class Demo4 {
/**
* @
*/
public static void main(String[] args) {
int[] array = {0,1,2,3,4,5,6,7,8,9};
Arrays.fill(array, 7, 9, 20);
sop("填充后的数组为:");
for(int x : array) //填充后的数组为:0 1 2 3 4 5 6 20 20 9
sop(x+" ");
//将数组排序
Arrays.sort(array);
sop("\n排序后的数组为:"); //排序后的数组为:0 1 2 3 4 5 6 9 20 20
for(int x : array)
sop(x+" ");
//在数组中检索26的位置
sop("\n 26在数组中的位置为:"+Arrays.binarySearch(array, 26)); // 26在数组中的位置为:-11(算法=-(插入点)-1)
sop("\n 5在数组中的位置为:"+Arrays.binarySearch(array, 5)); // 5在数组中的位置为:5
//将数组array同数组arrayB相比较
int[] arrayB = new int[10];
sop("\n与B数组比较的结果为:"+Arrays.equals(array, arrayB)); //与B数组比较的结果为:false
}
public static void sop(Object obj){
System.out.print(obj);
}
}