日期:2014-05-20 浏览次数:20734 次
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Test20130326 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
compose(new String[]{"A","B","C"},new String[]{"a","b","c"},new String[]{"1","2"});
}
public static void compose(Object ...obj){
int start = 0;
//int wLength = -1;
int hLength = obj.length;
for(Object arr:obj){
if(!(arr instanceof String[])){
System.out.println("The type is not right!");
return;
}
}
//wLength = ((String[])obj[hLength-1]).length;
StringBuilder s = new StringBuilder("");
getComposeString(s,(String[])obj[0],start,hLength,obj);
}
public static String getComposeString(StringBuilder str,String[] obj,int index,int maxSize,Object ...all){
//String[] temp = new String[obj.length] ;
//System.arraycopy(obj, 0, temp, 0, obj.length);
String temp = str.toString();
for(int i=0;i<obj.length;i++){
str = new StringBuilder(temp);
if(index==(maxSize-1)){
str.append(obj[i]);
//str.append(obj[i]);
System.out.println(str);
if(i ==obj.length-1){
return temp;
}
}else{
str.append(obj[i]);
str.append( getComposeString(str,(String[])all[index+1],index+1,maxSize,all));
}
}
return str.toString();
}
}