public static int binarySearch(int[] numbers, int left, int right, int key) {
if (left <= right) {
int mid = (left + right) / 2;
int midVal = numbers[mid];
if (midVal < key)
return binarySearch(numbers, left, mid - 1, key);
else if (midVal > key)
return binarySearch(numbers, mid + 1, right, key);
else
return mid;
}
return -1;
}