title: how to define a list of variable number of objects in groovy?
body: <p>I am learning groovy, I am using the <a href="http://docs.groovy-lang.org/next/html/documentation/working-with-collections.html" rel="nofollow noreferrer">documentation</a> and some youtube videos. I want for testing to find out how to declare an array of objects, but that array will have a <code>x</code> number of objects depending on some stuff. Here is what I tried:</p>
  <pre><code>class Issue {
      String type = &quot;&quot;
      String severity = &quot;&quot;
      String linestart = &quot;&quot; 
      String filename = &quot;&quot; 
      String meesage = &quot;&quot; 
  }
  
  def test(){
      Issue[] Issues = new Issue[5] 
      Issues[0].type = &quot;error&quot;
      println Issues[0].type
  }
  
  test()
  </code></pre>
  <p>what I get:</p>
  <pre><code>Caught: java.lang.NullPointerException: Cannot set property 'type' on null object
  java.lang.NullPointerException: Cannot set property 'type' on null object
  </code></pre>
  <p>I assume my array does not have 5 Issues objects inside, and that is why is trying to set on null object. How would be the right syntax to do so?</p>