java代码解决数字排列问题

从0,1,2,3中任意选出一个,有15组这样(0,1,2,,3)的数字,从每一组中找一个组成一个15位数字
现在已知道答案为4^15(4的15次方),我现在想得到所有的组合,请教各位大神

lz使用递归,不要用15层循环

以前用到过的一个排列组合方法,很快,供参考:

 public static void permutation(String[] str, int first, int end) {
        // 输出str[first..end]的所有排列方式
        if (first == end) { // 输出一个排列方式
            for (int j = 0; j <= end; j++) {
                System.out.print(str[j]);
            }
            System.out.println();
        }

        for (int i = first; i <= end; i++) {
            swap(str, i, first);
            permutation(str, first + 1, end); // 固定好当前一位,继续排列后面的
            swap(str, i, first);
        }
    }

    private static void swap(String[] str, int i, int first) {
        String tmp;
        tmp = str[first];
        str[first] = str[i];
        str[i] = tmp;
    }

 public class Test{

    public static int dataNum;
    public static int arry[],  num[];
    public static int end = 15;

    public static void main(String[] args)  {

        arry = new int[15];
        num = new int[end];
        dataNum = arry.length;
        for(int i = 0; i < 15; i++)
            arry[i] = i ;
        getResult(num, 0, end);
    }

    public static void getResult(int[] num, int step, int end){     
        int j;      
        if(step == end){
             for (j = 0; j < end; j++) {
                    System.out.print(num[j]);
                }
                System.out.println();
        }else{
            for(j = 0; j < dataNum; j++){
                if(step == 0 && arry[j] == 0) continue;
                else{
                    num[step] = arry[j];
                    getResult(num, step + 1, end);
                }
            }
        }
    }
}