Searches the specified array of longs for the specified value using the
binary search algorithm. The array must be sorted (as
by the sort(long[]) method) 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.
a | the array to be searched | |
key | the value to be searched for |
Searches the specified array of ints for the specified value using the
binary search algorithm. The array must be sorted (as
by the sort(int[]) method) 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.
a | the array to be searched | |
key | the value to be searched for |
Searches the specified array of shorts for the specified value using
the binary search algorithm. The array must be sorted
(as by the sort(short[]) method) 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.
a | the array to be searched | |
key | the value to be searched for |
Searches the specified array of chars for the specified value using the
binary search algorithm. The array must be sorted (as
by the sort(char[]) method) 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.
a | the array to be searched | |
key | the value to be searched for |
Searches the specified array of bytes for the specified value using the
binary search algorithm. The array must be sorted (as
by the sort(byte[]) method) 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.
a | the array to be searched | |
key | the value to be searched for |
Searches the specified array of doubles for the specified value using
the binary search algorithm. The array must be sorted
(as by the sort(double[]) method) 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. This method considers all NaN values to be
equivalent and equal.
a | the array to be searched | |
key | the value to be searched for |
Searches the specified array of floats for the specified value using
the binary search algorithm. The array must be sorted
(as by the sort(float[]) method) 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. This method considers all NaN values to be
equivalent and equal.
a | the array to be searched | |
key | the value to be searched for |
Searches the specified array for the specified object using the binary
search algorithm. The array must be sorted into ascending order
according to the
natural ordering
of its elements (as by the
sort(Object[]) method) prior to making this call.
If it is not sorted, the results are undefined.
(If the array contains elements that are not mutually comparable (for
example, strings and integers), it cannot be sorted according
to the natural ordering of its elements, hence results are undefined.)
If the array contains multiple
elements equal to the specified object, there is no guarantee which
one will be found.
a | the array to be searched | |
key | the value to be searched for |
ClassCastException | if the search key is not comparable to the elements of the array. |
Searches the specified array for the specified object using the binary
search algorithm. The array must be sorted into ascending order
according to the specified comparator (as by the
sort(T[], Comparator)
method) 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.
<T> | the class of the objects in the array | |
a | the array to be searched | |
key | the value to be searched for | |
c | the comparator by which the array is ordered. A null value indicates that the elements' natural ordering should be used. |
ClassCastException | if the array contains elements that are not mutually comparable using the specified comparator, or the search key is not comparable to the elements of the array using this comparator. |
Searches a range of
the specified array of longs for the specified value using the
binary search algorithm.
The range must be sorted (as
by the sort(long[], int, int) method)
prior to making this call. If it
is not sorted, the results are undefined. If the range contains
multiple elements with the specified value, there is no guarantee which
one will be found.
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Searches a range of
the specified array of ints for the specified value using the
binary search algorithm.
The range must be sorted (as
by the sort(int[], int, int) method)
prior to making this call. If it
is not sorted, the results are undefined. If the range contains
multiple elements with the specified value, there is no guarantee which
one will be found.
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Searches a range of
the specified array of shorts for the specified value using
the binary search algorithm.
The range must be sorted
(as by the sort(short[], int, int) method)
prior to making this call. If
it is not sorted, the results are undefined. If the range contains
multiple elements with the specified value, there is no guarantee which
one will be found.
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Searches a range of
the specified array of chars for the specified value using the
binary search algorithm.
The range must be sorted (as
by the sort(char[], int, int) method)
prior to making this call. If it
is not sorted, the results are undefined. If the range contains
multiple elements with the specified value, there is no guarantee which
one will be found.
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Searches a range of
the specified array of bytes for the specified value using the
binary search algorithm.
The range must be sorted (as
by the sort(byte[], int, int) method)
prior to making this call. If it
is not sorted, the results are undefined. If the range contains
multiple elements with the specified value, there is no guarantee which
one will be found.
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Searches a range of
the specified array of doubles for the specified value using
the binary search algorithm.
The range must be sorted
(as by the sort(double[], int, int) method)
prior to making this call.
If it is not sorted, the results are undefined. If the range contains
multiple elements with the specified value, there is no guarantee which
one will be found. This method considers all NaN values to be
equivalent and equal.
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Searches a range of
the specified array of floats for the specified value using
the binary search algorithm.
The range must be sorted
(as by the sort(float[], int, int) method)
prior to making this call. If
it is not sorted, the results are undefined. If the range contains
multiple elements with the specified value, there is no guarantee which
one will be found. This method considers all NaN values to be
equivalent and equal.
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Searches a range of
the specified array for the specified object using the binary
search algorithm.
The range must be sorted into ascending order
according to the
natural ordering
of its elements (as by the
sort(Object[], int, int) method) prior to making this
call. If it is not sorted, the results are undefined.
(If the range contains elements that are not mutually comparable (for
example, strings and integers), it cannot be sorted according
to the natural ordering of its elements, hence results are undefined.)
If the range contains multiple
elements equal to the specified object, there is no guarantee which
one will be found.
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for |
ClassCastException | if the search key is not comparable to the elements of the array within the specified range. | |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Searches a range of
the specified array for the specified object using the binary
search algorithm.
The range must be sorted into ascending order
according to the specified comparator (as by the
sort(Object[], int, int, Comparator)
method) prior to making this call.
If it is not sorted, the results are undefined.
If the range contains multiple elements equal to the specified object,
there is no guarantee which one will be found.
<T> | the class of the objects in the array | |
a | the array to be searched | |
fromIndex | the index of the first element (inclusive) to be searched | |
toIndex | the index of the last element (exclusive) to be searched | |
key | the value to be searched for | |
c | the comparator by which the array is ordered. A null value indicates that the elements' natural ordering should be used. |
ClassCastException | if the range contains elements that are not mutually comparable using the specified comparator, or the search key is not comparable to the elements in the range using this comparator. | |
IllegalArgumentException
| if fromIndex > toIndex | |
ArrayIndexOutOfBoundsException
| if fromIndex < 0 or toIndex > a.length |
Diagram: Arrays