Skip to content

Instantly share code, notes, and snippets.

@klmr
Created April 15, 2014 09:43
Show Gist options
  • Save klmr/10718254 to your computer and use it in GitHub Desktop.
Save klmr/10718254 to your computer and use it in GitHub Desktop.
Binary search implementation for a primitive type in Java.
static int binarySearch(int[] arr, int key) {
Object[] arrobj = new Object[arr.length];
for (int i = 0; i < arr.length; i++)
arrobj[i] = arr[i];
Object keyobj = key;
return binarySearch(arrobj, keyobj);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment