I was just experimenting with a two dimensional array of classes in java. I wrote the following (wrong) code:
public class GameEvent
{
static int LAUNCH_ALIEN = 0;
static int END = 1;
long time;
long cum_time;
int alien_type;
int event_code;
}
then
GameEvent[][] event_array = new GameEvent[MAX_LEVELS][MAX_EVENTS];
and accessed it with code like below (read comment in code):
event_array[lev][ctr].event_code = code; // nullpointer exception at runtime
So my question now is, what is the least painful way to change my code so that it works.