title: Store 2d array positions in ArrayList
body: <p>I want to store several 2d array positions in an ArrayList and I've set it up like so:</p>
  
  <pre><code>ArrayList&lt;Integer&gt; playedValues = new ArrayList&lt;Integer&gt;();
  playedValues.add(dataArray[0][1]);
  playedValues.add(dataArray[0][2]); //example of adding 2d array positions
  
  int size = playedValues.size(); //get size of ArrayList
  int gridIndex = playedValues.get(size - 1); //trying to set gridIndex to dataArray[0][2]
  
  cell.setCell(0, gridIndex); //this is where the error occurs
  
  //trying to pass gridIndex to here
  public void setCell(int value, int gridIndex) {
      gridIndex = value;
  }
  </code></pre>
  
  <p>My issue is when I try and pass <code>gridIndex</code> as a parameter to <code>setCell</code>, I get a <strong>NullPointerException</strong>. </p>
  
  <p>The method I'm passing it to seems to work fine in my tests, so I assume <code>gridIndex is not being set properly</code>. How do I make <code>playedValues</code> store <code>dataArray[][]</code> itself instead of the information <code>dataArray[][]</code> holds?</p>