Here you can find the source of sort(String prefix, int[] a, List
private static List<String> sort(String prefix, int[] a, List<String> list)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { private static List<String> sort(String prefix, int[] a, List<String> list) { if (a.length == 1) { list.add(prefix + a[0]);/* w w w. j ava2 s . c o m*/ } for (int i = 0; i < a.length; i++) { sort(prefix + a[i], copy(a, i), list); } return list; } private static int[] copy(int[] a, int index) { int[] b = new int[a.length - 1]; System.arraycopy(a, 0, b, 0, index); System.arraycopy(a, index + 1, b, index, a.length - index - 1); return b; } }