title: Repeat String Recursively
body: <p>This is homework. I get the logic but i got stuck on the code. I've done it with normally way and it takes 1 week to get the code. I need to get repeat string with recursive way in Java.
  This is my code :</p>
  
  <pre><code>static String repeatString (final int n, final String[] syllables, final String currentWord) {
      if (n == 0) {
          System.out.println(currentWord);
      } else {
          for (int i = 0; i &lt; syllables.length; i++) {
              repeatString(n - 1, syllables, currentWord + syllables[i]);
          }
      }
      return "";
  }
  </code></pre>
  
  <p>if i call in main method like </p>
  
  <pre><code>String[] str = {"a", "b"};
      repeatString(1, str, " ");
  </code></pre>
  
  <p>then i get output (a,b) if i change to </p>
  
  <pre><code>repeatString(2,str," ");
  </code></pre>
  
  <p>then i get output ( aa,ab,ba,bb) if i change to </p>
  
  <pre><code>repeatString(3,str," ");
  </code></pre>
  
  <p>then i get output (aaa,aab,aba,abb,baa,bab,bba,bbb) and so on.
  So basically it is like 2 to the power to n. If n=1, i got 2, if n=3, i got 8, and so on.
  I would be grateful if someone can help me to get this code in recursive way.</p>
  
  <p>Any help is much appreciated.</p>