/*
* 转为二维数组
* */
private String[][] changeList( List list,Integer row){
Integer Row = row==null||row<1?20:row;
// System.out.println(ye);
int listLength = list.size();
int yuShu = listLength%Row;
int ye = (yuShu==0)?(int)Math.ceil(listLength/Row):((int)Math.ceil(listLength/Row)+1);
String[][] arrList = new String[ye][];
for(int i=0;i<ye;i++){
if(ye==1){
arrList[i] = (String[])list.subList(0,listLength).toArray(new String[listLength]);
}else{
if(i==ye-1){
arrList[i] = (String[])list.subList(i*Row,listLength).toArray(new String[listLength-i*Row]);
}else{
arrList[i] = (String[])list.subList(i*Row,(i+1)*Row).toArray(new String[Row]);
}
}
}
return arrList;
}
java list转二维数组
最新推荐文章于 2024-06-06 09:32:02 发布