How to create and use a two dimensional array of classes
<p>I was just experimenting with a two dimensional array of classes in java. I wrote the following (wrong) code:</p>

<pre><code>public class GameEvent
{
    static int LAUNCH_ALIEN = 0;
    static int END = 1;

    long time;
    long cum_time;
    int alien_type;
    int event_code;
}
</code></pre>

<p>then</p>

<pre><code>GameEvent[][] event_array = new GameEvent[MAX_LEVELS][MAX_EVENTS];
</code></pre>

<p>and accessed it with code like below (read comment in code):</p>

<pre><code>event_array[lev][ctr].event_code = code; // nullpointer exception at runtime
</code></pre>

<p>So my question now is, what is the least painful way to change my code so that it works.</p>
