How to convert an ArrayList to a 2D Object.
My Current Code:
ArrayList<String> a = null;
a = new ArrayList<String>();
a.add("ABC");
a.add("DEF");
a.add("1");
a.add("1");
//Converter para Object 2D
int n = a.size();
System.out.println("Tamanho do Array: "+n);
Object[][] data = new Object[n][];
for (int i = 0; i < n; i++)
data[i] = a.toArray();
This way I can get the first value of ArrayList, but it repeats itself in all positions, I think the reason is because I'm not requesting other arraylist positions in line data[i] = a.toArray();
, I tried to change that line to data[i] = a.get(i);
but in this case I get the error " Type mismatch: can not convert from String to Object [] "