I am learning groovy, I am using the documentation and some youtube videos. I want for testing to find out how to declare an array of objects, but that array will have a x number of objects depending on some stuff. Here is what I tried:
class Issue {
String type = ""
String severity = ""
String linestart = ""
String filename = ""
String meesage = ""
}
def test(){
Issue[] Issues = new Issue[5]
Issues[0].type = "error"
println Issues[0].type
}
test()
what I get:
Caught: java.lang.NullPointerException: Cannot set property 'type' on null object
java.lang.NullPointerException: Cannot set property 'type' on null object
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?