It is printing out a few permutations but the rest are null and I'm not sure why. I need to but all the permutations into String[] and I can't import any other package except for util.Arrays. Please help!
import java.util.Arrays;
public class DIE
{
    public static String[] printPermutations(String s)
    {
        int l = s.length();
        int f = factorial(l);
        int count = 0;
        String[] array = new String[f];
        permute("", s, array, 0);
        Arrays.sort(array);
        return array;
    }
    private static String[] permute(String x, String s, String [] array, int count)
    {
        int l = s.length(); 
        if (l == 0)
        {
            array[count] = (x + s);
        }
        for (int i = 0; i < l; i++)
        {
            permute(x + s.charAt(i), s.substring(0, i) + 
                    s.substring(i +1, s.length()), array, count);
            count++;
        }
        return array;
    }
    public static int factorial(int l)
    {
        if (l == 1)
        {
            return 1;
        }
        else
        {
            int result = l * factorial(l - 1);
            return result;
        }
    }
    /*
    Do not edit anything below this comment.
    */
    public static void main(String[] args)
    {
        String[] permutations = printPermutations(args[0]);
        for(String p : permutations)
        {
            System.out.println(p);
        }
    }
}
 
     
    