?? binarysearchdemo.java
字號:
package onlyfun.caterpillar;
import java.util.Arrays;
public class BinarySearchDemo {
public static void main(String[] args) {
int[] arr1 = {10, 20, 30, 40, 50, 60, 70, 80, 90};
int result = Arrays.binarySearch(arr1, 6, 9, 85);
if(result > -1) {
System.out.printf("索引 %d 處找到數(shù)據(jù)%n", result);
}
else {
System.out.printf("插入點 %d %n", (result + 1) * -1);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -