日期:2014-05-20 浏览次数:20679 次
import java.util.Arrays; import java.util.LinkedList; import java.util.List; public class Test { public static void main(String[] args) { String[] array=new String[]{ "1","2","3","4" }; listAll(Arrays.asList(array),""); } public static void listAll(List candidate,String prefix){ System.out.println(prefix); for(int i=0;i<candidate.size();i++){ List temp = new LinkedList(candidate); listAll(temp,prefix+temp.remove(i)); } } }
for(int i=0;i<candidate.size();i++){ List temp = new LinkedList(candidate); listAll(temp,prefix+temp.remove(i)); }