Hi Moieen,
assume you have a sorted array with five elements like this
int[] array = { 0, 2, 4, 6, 7 };
If you search for an element which is present in array for example 4
int result = Arrays.binarySearch(array, 4);
your result will be the index of the element in this array: 2.
If you search for an element, which is not in array, for example 5
the result is an negative number, which represents an insertion point of this element to keep the array sorted. Imagine you have to put 5 in this array so that array stay sorted. The new array would be { 0, 2, 4, 5, 6, 7 }. The position of 5 would be 3. The result of binarySearch() is the fictive position of 5 in the new array negated and decremented ( -3 - 1 = -4). The result of search is -4.
The maximum positive result of the binarySearch() is the biggest index of the array ( which is in this example 4 ) and the minimum insertion point is the fictive position after the element 7 which is -6. So the range of the search results is from -6 to 4.
Sorry for my poor English