the code below is meant to count each time character 'x' occurs in a string but it only counts once ..
I do not want to use a loop.
public class recursionJava
{
   public static void main(String args[])
   {
      String names = "xxhixx";
      int result = number(names);
      System.out.println("number of x: " + result);
   }
   public static int number (String name)
   {
      int index = 0, result = 0;
      if(name.charAt(index) == 'x')
      {
         result++;
      }
      else
      {
         result = result;
      }
            index++;
      if (name.trim().length() != 0)
      {
        number(name);
      }
      return result;
   }
}
 
     
     
     
     
     
     
    