title: String Permutations explanation?
body: <p>I was looking up how to perform String Permutations and found the solution below. However I having real trouble understanding the logic being used. Especially this particular line. <strong>for(final String permutation : Permuatations(subList(head,words)))</strong> From what I can tell the author is calling a function on itself "Permutations" to perform the subList function within, which is very hard hard to wrap my head around. Could anyone make this a bit clearer to me? Any guidance would be much appreciated.</p>
  
  <pre><code>public static void main (String [] args)
      {
          for(final String s: Permuatations(Arrays.asList("This ","is ","String ")))
                  {
              System.out.println("6. THE FINAL OUTPUT " +s);
                  }
      }
  
      public static List&lt;String&gt; Permuatations(final List&lt;String&gt; words)
      {
          final List&lt;String&gt; perms = new ArrayList&lt;String&gt;();
          if (words.size() == 1)
          {
               perms.add(words.get(0));
               System.out.println("3. permuatations if words " + words);
               System.out.println("4. PERMS LIST " + perms);
          }
  
          else
          {
              for(final String head : words)
              {
                  for(final String permutation : Permuatations(subList(head,words)))
                  {
                      perms.add(head + permutation);
                      System.out.println("5 .SubList HEAD " + head + " PERMUATATION " + permutation  + " Word Size " + words.size() );
                  }
              }
          }
          return perms;
      }
  
  
  public static List&lt;String&gt; subList(final String elementToRemove, final List&lt;String&gt; elements)
  {
      final List&lt;String&gt; subList = new ArrayList&lt;String&gt;();
      for(final String s : elements)
      {
          //System.out.println(" 1. STRING s " + s + " ELEMENTS " + elements);
          if(!s.equals(elementToRemove))
          {
              System.out.println(" 1. STRING S " + s + " ELEMENTS " + elements);
              subList.add(s);
              System.out.println("2 STRING S " + s + " TO SUBLIST " + subList);
          }
  
  
      }
  
      return subList;
  }
  </code></pre>