存在list里的数组怎么取出来?
来源:百度知道 编辑:UC知道 时间:2024/07/08 20:28:35
存在list里的数组怎么取出来?或应该存在什么中能取出来
List里存的数组为Object[]类型的。
List里存的数组为Object[]类型的。
用get(index)方法,可以把list里的数组按索引读取出来
Iterator it=list.iterator();
while(it.hasnext()){
Object[] arr=(Object[])it.next();
System.out.println(arr[0]);
}
注意必须要强制类型转换,list的里面放的是什么就要转换成什么!
强制类型转换, 类似于: (Array)list[0]
Object[] ob=new Object[100];
Iterator it=list.iterator();
int i=0;
while(it.hasnext()){
ob[i++]=it.next();
}
new Array[] = (Array[])list.get(index)