title: Permutation of an ArrayList
body: <p>There's a lot of guide on finding Permutation for a String, but how would I do this for every element in an ArrayList? Given that: </p>
  
  <pre><code>ArrayList&lt;String&gt; list = [bob, cat, dog]
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>[bob, cat, dog]
  [bob, dog, cat]
  [dog, bob, cat]
  [dog, cab, bob]
  ....
  </code></pre>
  
  <p>Here's a code that I have that will permute a single <em>word</em>:</p>
  
  <pre><code>public class permutations {
  
  public ArrayList&lt;String&gt; performPermutations(String s){
      ArrayList&lt;String&gt; arrayList = new ArrayList&lt;String&gt;();
      if (s == null) {
          return null;
      }
  
      else if (s.length() == 0) {
          arrayList.add("");
          return arrayList;
      }
  
      else {
          for (int i = 0; i &lt; s.length(); i++) {
              ArrayList&lt;String&gt; remaining = performPermutations(s.substring(0, i) + s.substring(i + 1));
              for (int j = 0; j &lt; remaining.size(); j++) {
                  arrayList.add(s.charAt(i) + remaining.get(j));
              }
          }
          return arrayList;
      }
  }
  
  
  public static void main(String[] args) {
      permutations p = new permutations();
      ArrayList&lt;String&gt; arr = p.performPermutations("abc");
          for(int i = 0; i&lt;arr.size();i++) {
              System.out.println(arr.get(i));
          }
   }
  </code></pre>