import java.util.ArrayList;
import java.util.List;
public class PaiLie {
/**
* @param args
*/
public static void main(String[] args) {
List<String> strList = new ArrayList<String>();
strList.add("a");
strList.add("b");
strList.add("c");
quanpailie(strList, 0);
}
/**
* 按递归算法列出全排列
* @param strList
* @param cur
*/
private static void quanpailie(List<String> strList, int cur)
{
if(cur >= strList.size()) {
System.out.println(strList);
return;
}
for(int i = cur; i < strList.size(); i++)
{
wape(strList, cur, i);
quanpailie(strList, cur+1);
wape(strList, cur, i);
}
}
/**
* 交换第i和j位置的值
* @param strList
* @param i
* @param j
*/
private static void wape(List<String> strList, int i,int j )
{
String temp = strList.get(i);
strList.set(i, strList.get(j));
strList.set(j, temp);
}
}