将对象数组列表转换为对象数组。
//package com.nowjava;/**来 自 时代Java公众号 - N o w J a v a . c o m**/ import java.lang.reflect.Array; import java.util.List; public class Main { public static void main(String[] argv) throws Exception { List list = java.util.Arrays.asList("asdf", "nowjava.com"); Class arrayElements = String.class; System.out.println(java.util.Arrays .toString(listOfArraysToDoubleArray(list, arrayElements))); } /** * Convert list of arrays of objects to array of arrays of objects. * * @param <T> * type of the array * * @param list * {@link List}, list of arrays * @param arrayElements * Class, class of the array type * @return Object */ @SuppressWarnings("unchecked") public static <T> T[][] listOfArraysToDoubleArray(List<T[]> list, Class<T> arrayElements) { T[][] result = (T[][]) Array.newInstance(arrayElements, new