- import java.util.*;
- public class QuanPaiLie{
- private static int NUM = 5;
- public static void main(String[] args){
- Integer[] integer = {1,2,3,4,5};
-
- List<Integer>list = new ArrayList<Integer>(Arrays.asList(integer));
-
- method(list,new ArrayList<Integer>());
- }
- private static void method(List<Integer>list,List<Integer>list1){
-
-
- if(list1.size()== NUM){
- for(Integer i :list1){
- System.out.print(i);
-
- }
- System.out.println();
- return;
- }
-
- //System.out.println(list.size());
- for(int x=0;x<list.size();x++){
-
- List<Integer>newList = new ArrayList<Integer>(list);
- List<Integer>newList1 = new ArrayList<Integer>(list1);
- newList1.add(newList.get(x));
- newList.remove(x);
- method(newList,newList1);
-
- }
-
-
-
- }
- }
复制代码 |