title: Need help understanding this double recursion
body: <p>I have some code </p>
  
  <pre><code>public class NameGenerator {
  public static void main (String[] args)
  {
      List&lt;String&gt; result = new ArrayList&lt;String&gt;();
      buildNameChoices("von.del.smith", result);
      System.out.println(result);
  }
  public static void buildNameChoicesHelper(String[] nameArray, int nameIndex,
      String firstName, String lastName, List&lt;String&gt; result) {
  
      if(nameIndex &gt;= nameArray.length) {
          if(lastName.length() &gt; 0) {
              result.add(firstName + lastName);
          }
      }
      else {
          System.out.println("Calling first buildNameChoices");
          buildNameChoicesHelper(nameArray, nameIndex + 1,firstName, lastName, result);
          System.out.println("Calling second buildNameChoices");
          buildNameChoicesHelper(nameArray, nameIndex + 1,firstName, lastName + "." + nameArray[nameIndex], result);
      }   
  }
  public static void buildNameChoices(String nameStr, List&lt;String&gt; result) {
      String[] nameArray = nameStr.split("\\.", -1);
      for(int i = 0; i &lt; nameArray.length; i++) {
          System.out.println("Inside for loop");
          buildNameChoicesHelper(nameArray, i + 1, nameArray[i], "", result);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>that generates all possible combinations of a name string that it is passed. The code works, and I understand how the recursion works on some level, but the double recursive call is really confusing me. I've been looking at it for quite some time, and I'm having trouble grasping exactly what it's doing. Any help on this would be greatly appreciated. I've tried debugging through it, but I'm still not really able to understand it.</p>