62,614
社区成员
发帖
与我相关
我的任务
分享
int[] num = {2,1,3,4,5};
Arrays.sort(num);
System.out.println(Arrays.toString(num));
Arrays.fill(num,1,2,6);
System.out.println(Arrays.toString(num));
//Searches the specified array of ints for the specified value using the binary search algorithm.
//The array must be sorted (as by the sort(int[]) method) prior to making this call.
//If it is not sorted, the results are undefined.
//If the array contains multiple elements with the specified value,
//there is no guarantee which one will be found.
System.out.println(Arrays.binarySearch(num,6));