There is a list:
List<Integer[]> myList = new ArrayList<Integer[]>();
It contains a sigle entry, but might contain multiple entries:
myList = [[2,null,1,null,null,3,6,1,1]]
I need to convert this list into the array Integer[][], but the conversion fails due to nulls:
Integer[] myArr = myList.toArray(new Integer[myList.size()]);
How to solve this issue?
Edit#1
I need to get:
myArr = [2,null,1,null,null,3,6,1,1]
Try this (assuming you have actually the
List<Integer[]>you talked about in your comment):If you convert a list of arrays to an array, you’ll get a 2 dimensional array and thus your parameter should be one too.