public class StringPermutation {

//----------------------------------------------------------------------------

         private static char source[] = {'c', 'a', 'r', 'b', 'o', 'n'};

         private static char result[] = new char[6];

         private static boolean picked[] = new boolean[6];

//----------------------------------------------------------------------------

         public static void main(String[] args) {

                      // initialize that none of characters was picked

                      java.util.Arrays.fill(picked, false);

                      pickCharAt(0);

         }

//----------------------------------------------------------------------------        

         private static void pickCharAt(int position) {

                      // print out if 6 positions already filled

                      if (position > 5)

                                   System.out.println(String.valueOf(result));

                      // pick a remain character for current position

                      else

                                   for (int i=0; i<6; i++) {

                                                 // if the character source[i] still not picked then pick it

                                                 if (!picked[i]) {

                                                      result[position] = source[i];

                                                      picked[i] = true;

                                                      // fetch for next position

                                                      pickCharAt(position + 1);

                                                      // return the character source[i] when recur back

                                                      picked[i] = false;

                                         }

         }

}