I am writing a method which converts Integer data type from a List of lists, to a primitive type \"int\" of \"array of array\".
Question
<
This
tempArray[i][j] = ll.get(j);
should be something like
tempArray[i][j] = ll.get(i).get(j);
However, you have a few other bugs (you need to declare the arrays); you can also shorten the initialization routines. Something like,
static int[][] convert(int[] set) {
List> ll = new ArrayList<>();
ll.add(Arrays.asList(1,2));
ll.add(Arrays.asList(2));
ll.add(Arrays.asList(2,3));
System.out.println(ll + " " + ll.size());
int[][] tempArray = new int[ll.size()][];
for (int i = 0; i < ll.size(); i++) {
tempArray[i] = new int[ll.get(i).size()];
for (int j = 0; j < tempArray[i].length; j++) {
tempArray[i][j] = ll.get(i).get(j);
}
}
return tempArray;
}