<p>I'm used to working with PHP but lately I've been working with Java and I'm having a headache trying to figure this out. I want to save this representation in Java:</p>

<pre>
Array ( 
        ["col_name_1"] => Array ( 
                               1 => ["col_value_1"], 
                               2 => ["col_value_2"], 
                               ... , 
                               n => ["col_value_n"] 
                          ),
        ["col_name_n"] => Array ( 
                               1 => ["col_value_1"], 
                               2 => ["col_value_2"], 
                               ... , 
                               n => ["col_value_n"] 
                          )
)
</pre>

<p>Is there a clean way (i.e. no dirty code) to save this thing in Java? Note; I would like to use Strings as array indexes (in the first dimension) and I don't know the definite size of the arrays.. </p>

You want a
Map
, which are keyed by just about anything.
HashMap
s work in most cases.
Something like this.
```
```
List<String> col1Vals = new java.util.ArrayList<String>();
col1Vals.add("col_value_1");
col1Vals.add("col_value_2");
Map<String, List<String>> map = new HashMap<String, List<String>>();
map.put("col_name_1", col1Vals);
```
```
If you want something simpler, the
commons-lang
library has a
MultiMap
.