Karen Haq wrote:Is this method taking an array full of Objects as its parameter? And what is Object key, the second parameter? I'm trying to understand the API as I'm learning Java.
The documentation explains what those parameters are:
Parameters:
a - the array to be searched
key - the value to be searched for
The method checks if the object that
key refers to is present in the array
a. It returns the index of the object in the array if it was found, and a negative value otherwise. So you can check the return value of the method, and if it's less than zero, the object was not found in the array.
Note that the array must be sorted in order for this method to work properly; if the array is not sorted, you'll get undefined results.