public class Goods{
//在domain类中定义一个将good转为一维数组的方法
public String[] toStringAry(){
String[] ary=new String[4];
if(number!=null)
ary[0]=number;
if(name!=null)
ary[1]=name;
if(price!=null)
ary[2]=price;
if(unit!=null)
ary[3]=unit;
return ary;
}
}
---------使用时---------
String[] thead = { "水果编号", "水果名称", "水果单价", "计价单位" };
String [][] tbody=new String [goods.size()][];
for (int i = 0; i < goods.size(); i++) {
Goods temp=goods.get(i);
tbody[i]=temp.toStringAry(); //在这里使用
} |