ArrayList转换为二维数组有问题,请指点
public String[][] getArray(ArrayList rs){
rs = this.doExcel();
String[][] excel_str=new String[rs.size()][]; //转换为二维数组
try{
for(int i=0;i<excel_str.length;i++){
ArrayList temp=(ArrayList)rs.get(i);
excel_str[i]=(String[])(temp.toArray(new String[0]));
}
}catch(Exception e){
System.err.println(e.getMessage());
}
return excel_str;
}
这是我写的一个方法,运行时可以得到ArrayList,是正确的结果,但是在执行到excel_str[i]=(String[])(temp.toArray(new String[0]));这行语句时,就有问题,catch到null,不知道为什么会这样,那位能指点一二,谢谢