I am new to using arrays of objects but can\'t figure out what I am doing wrong and why I keep getting a Null pointer exception. I am trying to create an Theatre class with
replace
arrayOfSpotlights[i].turnOn();
with
arrayOfSpotLights[i] = new Spotlight(); arrayOfSpotlights[i].turnOn();
The line
arrayOfSpotlights = new spotlight[N];
will create an array of spotlights. It will however not populate this array with spotlights.