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:
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'] ) )
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..
You can use a Map and a List (these both are interfaces implemented in more than one way for you to choose the most adequate in your case).
For more information check the tutorials for Map and List and maybe you should start with the Collections tutorial.
An example: