不说废话了,直接上代码
public void range(){
List<String> pre = new ArrayList<>(Arrays.asList("姓"));
List<String> mid = new ArrayList<>(Arrays.asList("名"));
List<String> num = new ArrayList<>(Arrays.asList("1","2","3"));
List<String> abc = new ArrayList<>(Arrays.asList("a","b","c"));
List<List<String>> list = new ArrayList<>(Arrays.asList(pre, mid, num, abc));
List<String> total = new ArrayList<>();
for (int i = 0; i < list.size(); i++){
List<String> strings = list.get(i);
List<String> array = new ArrayList<>(); // 准备替换
for (int j = 0; j < strings.size(); j++) {
if (i == 0 ){
total.add(strings.get(j));
}else {
for (int z = 0; z < total.size(); z++){
array.add(total.get(z) + strings.get(j));
}
}
}
if (i != 0){
total = new ArrayList<>(array);
}
}
}