二分法查找
package com.bjpowernode.t01;
import java.util.Arrays;
/*
* 二分法查找
* 首先要确保该数组是排好序的
*/
public class TestArray12 {
public static void main(String[] args) {
//11 -- 4
int[] a = {2,4,7,8,9,10,11,15,18};
int index = Arrays.binarySearch(a, 11);
System.out.println("11在数组中的下标是:" + index);
}
}