title: Java need help Deserializing multidimensional array
body: <p>I'm writing a module which serializes others and I've got everything working only I'm unsure of how I should deserialize multidimensional arrays.</p>
  
  <p>The problem is, I need to deserialize something like this(There are other attributes for each node, such as the objects SUID, that I've excluded for simplicity's sake.)</p>
  
  <pre><code>&lt;var object="[[I"&gt;
      &lt;_0 object="[I"&gt;
          &lt;_0 object="java.lang.Integer"&gt;1&lt;/_0&gt;
          &lt;_1 object="java.lang.Integer"&gt;2&lt;/_1&gt;
      &lt;/_0&gt;
      &lt;_1 object="[I"&gt;
          &lt;_0 object="java.lang.Integer"&gt;3&lt;/_0&gt;
          &lt;_1 object="java.lang.Integer"&gt;4&lt;/_1&gt;
      &lt;/_1&gt;
  &lt;/var&gt;
  </code></pre>
  
  <p>Where the "object" attribute on each node describes what object it is. If it is an array of a primitive type, it will begin with an array of <code>[</code> brackets, where each one represents a count in its depth. I.e:</p>
  
  <pre><code>type int[][] = [[I
  
  type int[] = [i
  </code></pre>
  
  <p>The problem is I don't know how I'd programatically create an array with a depth of x? I.e, if I had to do it my way it would probably be something like:</p>
  
  <pre><code>switch(iArrayDepth)
  {
      case 1:
          return new ArrayList&lt;Integer&gt;();
      case 2:
          return new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;();
      case 3:
          return new ArrayList&lt;ArrayList&lt;ArrayList&lt;Integer&gt;&gt;&gt;();
  etc...
  }
  </code></pre>
  
  <p>There must be a better way of doing it :S</p>
  
  <p>Another problem arises when I need to unbox this array and make it a mutlidimensional array of a primitive type. </p>