The Arrays class
contains a static binarySearch method
The method returns either
- The index of the element if element is found
- Or -k - 1 where k is the position before which the
element should be inserted
To search an integer array
int[] intArray = { 1, 4, 9 };
int v = 7;
int pos = Arrays.binarySearch(intArray, v);
//returns -3; v should be inserted before position 2