title: Java - using recursion to create all substrings from a string
body: <p>The following code in Java uses recursion to create all possible substrings from a string.
  I am wondering is there a better way of coding this?  I want to use recursion.</p>
  
  <pre><code>public class main {
  
      public static void main(String[] args) {
          generate("hello");
      }
  
      public static void generate(String word) {
          if (word.length() == 1) {
              System.out.println(word);
              return;
          }else{
              System.out.println(word);
              generate(word.substring(0, word.length()-1)); 
              generate(word.substring(1, word.length())); 
          }
  
      }
  
  }
  </code></pre>
  
  <p>FAQ
  Q - Why do I want to do this using recursion?
  A - Because the CEO of StackOverflow says recursion is important
  <a href="http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html" rel="noreferrer">http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html</a></p>