List permu(String s){
List result=new ArrayList();
if("".equals(s)){
result.add("");
return result;
}
String c = s.substring(0, 1);
List res = permu(s.substring(1));
for(int i=0; i<res.size(); ++i){
String t = (String) res.get(i);
for(int j=0; j<=t.length(); ++j){
StringBuffer u = new StringBuffer(t);
u.insert(j, c);
result.add(u.toString());
}
}
return result;
}
@Test
public void testPermu() throws Exception {
System.out.println(permu("abc"));
}