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

java, jtable, swing

Solution

You probably want to look at implementing your own table model: JTable(TableModel dm)

You can create a class that extends AbstractTableModel and delegates to a List, or any other suitable data structure.

Problem

It looks like the `JTable` construct likes `String[][]`... but I like to use smarter containers until I have to use something else. been using `ArrayList<ArrayList<String>>`, now I need to make `JTable` happy with `String[][]`. I found a real easy way to convert an `ArrayList<String>` to a `String[]` using `toArray()`, but not finding the easy converter for multidimensional arrays. I want to go from `ArrayList<ArrayList<String>>` to `String[][]` in the least number of lines. I have been searching the library and cannot seem to find this converter, and hoping someone could suggest a good solution for this. Thanks in advance.

Original source

Related problems