title: function wont return despite condition of the return being true
body: <p>In a binary search on an array.</p>
  <pre class="lang-java prettyprint-override"><code>private int binarySearch(int first, int last, String name){
      int middle = (first+last)/2;
  
      if (catalogue[middle].getName().equals(name)){
          return catalogue[middle].getNumber();
      }
      else{
          if(catalogue[middle].getName().compareTo(name) &lt; 0){
              binarySearch(middle, last, name);
          }
          else {
              binarySearch(first, middle, name);
          }
      }
  
      return -1;
  }
  </code></pre>
  <p>With each element in the array <code>catalogue</code> being an object <code>Entry</code> with the attribute <code>name</code> and <code>number</code>. <code>binarySearch</code> should find the <code>Entry</code> with the same <code>name</code> and return the <code>number</code> of that <code>Entry</code>.</p>
  <p>For some reason</p>
  <pre><code>if (catalogue[middle].getName().equals(name)){
      return catalogue[middle].getNumber();
  }
  </code></pre>
  <p>The method will only return -1 despite seemingly reaching the other return statements?</p>