package com.Summer_0420.cn; import java.util.Arrays; /**
* @author Summer
* 二分法binadySearch的用法(测试)
*/
public class TestMethod04 {
public static void main(String[] args) {
int [] a = {1,2,3,4,5,6,7,8,9,10};
int index = Arrays.binarySearch(a, 2);
System.out.println(index);//输出1
int index1 = Arrays.binarySearch(a, 11);
System.out.println(index1);//输出-11
a = null;
int index2 = Arrays.binarySearch(a, 3);
System.out.println(index2);//输出空指针异常java.lang.NullPointerException
} }