title: Two-dimensional array of Lists
body: <p>I'm in the need of a two dimensional matrix of list, e.g. ArrayList, and I'm wondering what is most preferable in this case. It only needs to be 4x4 in size.</p>
  
  <p>Should I use something like</p>
  
  <pre><code>    ArrayList[][] foo = new ArrayList[4][4];
  </code></pre>
  
  <p>or</p>
  
  <pre><code>    ArrayList&lt;SomeClass&gt;[][] foo = new ArrayList[4][4];
  </code></pre>
  
  <p>and initialize every element with the proper type in a for loop or</p>
  
  <pre><code>    ArrayList&lt;ArrayList&lt;ArrayList&lt;SomeClass&gt;&gt;&gt; foo = ArrayList&lt;ArrayList&lt;ArrayList&lt;SomeClass&gt;&gt;&gt;();
  </code></pre>
  
  <p>The first method generates warnings like it should be parametrized and if I add use the second I get unchecked conversion warnings. But if I loop over the elements and initialize them there should not be any problem even if I still get the warning? The last method does not generate any warnings and probably works fine but it feels kinda messy.</p>
  
  <p>EDIT: Got some nice answers to my question even if it was a bit unclear. But it was basically how to make a table of Lists. Creating a custom class to handle rows/columns it made it a a lot easier.</p>