🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
```Java public static int binarySearch(int[] a, int key) { int low = 0; int high = a.length - 1; while (low <= high) { int middle = low + (high - low) / 2; if (key < a[middle]) { high = middle - 1; } else if (key > a[middle]) { low = middle + 1; } else { return middle; } } return -1; } ```