ArrayList <ArrayList <String>> to String [] []

It seems like the design is JTablelike String[][]... but I like to use smarter containers until I use something else. used ArrayList<ArrayList<String>>, now i need to make JTablehappy with String[][].

I found a simple easy way to convert ArrayList<String>to String[]using toArray(), but not find a simple converter for multidimensional arrays.

I want to go from ArrayList<ArrayList<String>>to String[][]to the least number of lines.

I was looking for a library and cannot find this converter and hope someone can offer a good solution for this.

Thanks in advance.

+3
source share
3 answers

, : JTable (TableModel dm)

, AbstractTableModel .

+6

ArrayList<ArrayList<String>> . ArrayList<String> s, ArrayLists , , .

, - :

ArrayList<ArrayList<String>> data;

//...

String[][] converted = new String[data.size()][];
for (int i = 0; i < converted.length; i++)
    converted[i] = data.get(i).toArray(new String[data.get(i).size()]);
+7

I would like to use ArrarList> to store the value / quantity in a list of items in another ArrayList.

but I don’t know where to start.

like

ArrarList> itemQuantity = fizzDrinks.get (0) and 15

please help

0
source

All Articles