i have a ArrayList
with ObjectArrays like this:
ArrayList<Object[]> objectList = new ArrayList<Object[]>();
i would like to convert it to:
Object[][] objectListAsArray = ...
My first thought was to convert the list with objectArrays to an array:
objectList.toArray()
... but this will only return a single Object[]
. Can someone help me to find a solution?
Regards mmm...
Object[][] array = list.toArray(new Object[list.size()][]);
As Peter noted, your Object[]
will be shared between the list and the array. If you want different arrays, you'd have to iterate the list and copy the arrays.
只需尝试:
Object[][] objectListAsArray = objectList.toArray(new Object[0][]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.