a bc d ef 输出 abde abdf acde acdf
public static void main(String[] args) {
String str="ac bc dea d";
String a[]=str.split(" ");
List<String[]> list=new ArrayList<>();
for(int i=0;i<a.length;i++){
String b[]=a[i].split("");
list.add(b);
}
List<String[]> rst= getECSStr(list,0,null);
for(String c[]:rst){
for(int i=0;i<c.length;i++){
System.out.print(c[i]);
}
System.out.print("
");
}
}
public static List<String[]> getECSStr(List<String[]> dataList, int index, List<String[]> resultList){
if(index==dataList.size()){
return resultList;
}
List<String[]> rstTmp=new ArrayList<>();
if(index==0){
String tmp[]=dataList.get(0);
for(String a:tmp){
rstTmp.add(new String[]{a});
}
}else{
String tmp[]=dataList.get(index);
for(String a[]:resultList){
for(String str:tmp){
String tmpArr[]=new String[a.length+1];
for(int i=0;i<a.length;i++){
tmpArr[i]=a[i];
}
tmpArr[a.length]=str;
rstTmp.add(tmpArr);
}
}
}
return getECSStr(dataList,++index,rstTmp);
}