如何在Java中将数组列表转换为二维数组?
//Prepare the list
List<Object[]> conf = new LinkedList<Object[]>();
conf.add(new Object[]{ "FOO", "BAR"});
conf.add(new Object[]{ "FOO", "BAR"});
我试过了:
Object[][] array = (Object[][]) conf.toArray(new Object[0]);
但它失败了ClassCastException
:
java.lang.RuntimeException: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [[Ljava.lang.Object;