title: Basic recursive enumeration explanation
body: <p>I have a simple class that computes and ultimately prints all possible combinations of X amount of 6-sided die, using recursive enumeration with a process function. However, while this program works (using found algorithms for the enumeration process), I'm not entirely certain what exactly the recursion is doing that allows the class to sort through <strong>ALL</strong> possibilities.</p>
  
  <p>The main method is calling the enumeration directly,</p>
  
  <pre><code>enumerate(N, 0, new int[N]);
  </code></pre>
  
  <p>The enumeration method is quite straightforward,</p>
  
  <pre><code>    public static void enumerate(int N, int k, int[] a) {
      if (k == N) {
          process(a);
          return;
      }
      for (int i = 0; i &lt; 2; i++) {
          a[k] = i;
          enumerate(N, k + 1, a);
      }
  }
  </code></pre>
  
  <p>The process method that is called effectively does nothing at this point, and just prints the array that's passed to it</p>
  
  <pre><code>    public static void process(int[] a) {
      for (int i : a) {
          System.out.print(i);
      }
      System.out.println();
  }
  </code></pre>
  
  <p>TL;DR - I have an enumerate method that seemingly <strong>returns</strong> when <code>k==n</code> - that is, a complete array of possibilities is complete. However, the class returns <strong>all possible combinations</strong>. What exactly is the recursive function doing that allows this to be possible? Why doesn't the program stop when the enumerate method is returned after forming a complete combination?</p>