title: Java Recursion - counting Characters in a string
body: <p>I'm trying to find the number of occurrences "character" is found in "str" using recursion. I think I have the concept of what to do but for some reason the code does not work when I test it out...do you know why its wrong?</p>
  
  <pre><code>   public static int countChar(String str, String character) {
      int number = 0;
      if(str.length()==1) {
          return number;
      }
      if (!(str.substring(0,1).equals(character))) {
          return countChar(str.substring(1), character);
      } else {
          number = number + 1;
          return countChar(str.substring(1), character);
      }
  }
  </code></pre>