Java - Finding permutations of a word using recursion?
<p>I have a program, that will find all the possible permutations of a word given as a command line argument, but am unable to get any output from the program, the program compiles fine, and when I have run through the program, i can't see what's wrong. Any ideas?   </p>

<pre><code>    import java.io.*;
02   
03  public class Anagrams
04  {
05      private static char [] word;
06      private static char [] permutation;
07      private static boolean [] characterUsed;
08   
09       
10       
11      public static void main(String [] args)throws Exception
12      {
13        
14         word = args[0].toCharArray();
15         permutation = new char[word.length];
16         characterUsed =  new boolean[word.length];
17         printPermutations(0);
18      }//main
19       
20     private static void printPermutations(int currentIndex)throws Exception          
02     {
03   
04      if(currentIndex == permutation.length)
05          System.out.println(permutation);
06      else
07      {
08          for(int index=0;index&lt;word.length-1;index++)
09          {
10  //if the character at that index hasn't been used       
11             if(!characterUsed[index]);
12              {
13                 //mark character at this position as in use
14                 characterUsed[index] = true;
15                 //put the character in the permutation
16                permutation[index]= word[currentIndex];
17                 printPermutations(currentIndex +1);
18                 characterUsed[index] = false;
19               }//if
20           }//for
21         }//else
22       }//printPermutation
41  }//Anagrams
</code></pre>
