Java class member construction
<p>I'm just learning java out of a what seems to be an excellent book, but I'm having a problem following one of the examples. In the code that follows, I'm obviously missing a step in using a member variable of a simple class. What am I doing wrong?</p>

<p>Here's the code:</p>

<pre><code>class Dog {
    String name;
    String color;
}

class DogsExample {
    public static void main(String[] args) {

    Dog [] myDogs = new Dog[3];

    myDogs[0].name = "Rover";
    }
}
</code></pre>

<p>When I run this program, it causes a null pointer exception where I assign a value to the name member variable:</p>

<pre><code>$ java DogsExample
Exception in thread "main" java.lang.NullPointerException
    at DogsExample.main(DogsExample.java:11)
</code></pre>

<p>Why can't I do this?</p>
