static int binarySearch(byte[] a, byte key)
static int binarySearch(char[] a, char key)
static int binarySearch(float[] a, float key)
static int binarySearch(int[] a, int key)
static int binarySearch(Object[] a, Object key)
static int binarySearch(Object[] a, Object key, Comparator c)
static int binarySearch(short[] a, short key)
_INSERT_METHOD_SIGNATURE_HERE_
Description:
binarySearch(byte[] a, byte key) method:
Searches the specified array of bytes for the specified value using the binary search algorithm. The array must be sorted prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements with the specified value, there is no guarantee which one will be found.
binarySearch(char[] a, char key) method:
Searches the specified array of chars for the specified value using the binary search algorithm. The array must be sorted prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements with the specified value, there is no guarantee which one will be found.
binarySearch(float[] a, float key) method:
Searches the specified array of floats for the specified value using the binary search algorithm. The array must be sorted prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements with the specified value, there is no guarantee which one will be found.
binarySearch(int[] a, int key) method:
Searches the specified array of ints for the specified value using the binary search algorithm. The array must be sorted prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements with the specified value, there is no guarantee which one will be found.
binarySearch(Object[] a, Object key) method:
Searches the specified array of Objects for the specified value using the binary search algorithm. The array must be sorted into ascending order according to the natural ordering of its elements prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements equal to the specified object, there is no guarantee which one will be found.
binarySearch(Object[] a, Object key, Comparator c) method:
Searches the specified array of Objects for the specified value using the binary search algorithm. The array must be sorted into ascending order according to the specified comparator prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements equal to the specified object, there is no guarantee which one will be found.
binarySearch(short[] a, short key) method:
Searches the specified array of shorts for the specified value using the binary search algorithm. The array must be sorted prior to making this call. If it is not sorted, the results are undefined. If the array contains multiple elements with the specified value, there is no guarantee which one will be found.
Example
int intArr[] = {30,20,5,12,55};
Arrays.sort(intArr);
Logger.log("The index of element 12 is : " + Arrays.binarySearch(intArr,12));
The example above returns the index value of element and writes it to the logger.