title: Java String Function
body: <p>Describe the following two functions and whether they perform the same task -</p>
  
  <pre><code>public int Jane1(String input, char aChar) {
      int count = 0;
      int index = input.indexOf(aChar);
      while (index &gt;= 0) {
          count++;
          index = input.indexOf(aChar, index + 1);
      }
      return count;
  }
  
  public int Jane3(String input, char aChar) {
      int index = input.indexOf(aChar);
      if (index &lt; 0) return 0;
      return Jane3(input.substring(index + 1), aChar) + 1;
  }
  </code></pre>
  
  <p>I think they don't perform the same task, however I'm not sure of the explanation. Jane3 function uses a recursive call to return the length of the String input, where as Jane1 returns the length of the String. Struggling to get my head around the difference between returning sub string (which I think is a String result), and index of?</p>