package com.charles.algorithm; import java.util.LinkedList; import java.util.Queue; public class Permutation { public static void main(String[] args) { Queue<String> queue = new LinkedList<String>(); queue.add("A"); queue.add("B"); queue.add("C"); /*queue.add("D"); queue.add("E");*/ rankList(queue, ""); } public static void rankList(Queue<String> chars, String param) { if (null == chars || 0 == chars.size()) { if(null != param && 0 < param.length()){ System.out.println(param); } return; } String temp = param; for (String chara : chars) { param = temp + chara; Queue<String> charz = new LinkedList<String>(chars); charz.remove(chara); rankList(charz, param); } } }