title: Defining the capacity of a multi-dimensional arraylist
body: <p>I have created a class called <code>Grid</code> and I'm struggeling to define the capacity of a nested <code>ArrayList</code>. This is what I currently have:</p>
  
  <pre><code>public class Grid extends GameObject {
  
     private int cols;
     private int rows;
     private int colWidth;
     private int rowHeight;
     private ArrayList&lt;ArrayList&lt;GameObject&gt;&gt; contents;
  
     public Grid(int x, int y, int cols, int rows, int colWidth, int rowHeight, ID id) {
         super();
         this.x = x;
         this.y = y;
         this.cols = cols;
         this.rows = rows;
         this.colWidth = colWidth;
         this.rowHeight = rowHeight;
  
         //Here I want to define the contents
  
         this.width = colWidth * cols;
         this.height = rowHeight * rows;
         this.id = id;
     }
   }
  </code></pre>
  
  <p>The code should look something like this:</p>
  
  <pre><code>this.contents = new ArrayList&lt;ArrayList&lt;GameObject&gt;(cols)&gt;(rows);
  </code></pre>
  
  <p>But this gives an error. Does anyone know how to solve this issue, I would really appreciate it! Thanks in advance!</p>