title: Using Binary Search to Find Insertion Points in an Array
body: <p><strong>I need to modify the below code to use binary search to return the Index of an Insertion Point in a sorted  Array</strong></p>
  
  <p>for Instance if objArray={1,2,4} and searchObj=3</p>
  
  <p>the binarysearch function should return 2 as the Index where 3 should be inserted </p>
  
  <pre><code>public int binarySearch(Comparable[] objArray, Comparable searchObj)
  {
      int low = 0;
      int high = objArray.length - 1;
      int mid = 0;
      while (low &lt;= high)
      {
          mid = (low + high) / 2;
          if (objArray[mid].compareTo(searchObj) &lt; 0)
          {
              low = mid + 1;
          }
          else if (objArray[mid].compareTo(searchObj) &gt; 0)
          {
              high = mid - 1;
          }
          else
          {
              return mid;
          }
      }
      return -1;
  }
  </code></pre>
  
  <p>Thanks</p>