title: Java NullPointerException in .containsKey
body: <p>I'm very new to Java. Trying to access a field in the HashMap <code>observationMap</code>, and am told there is a <code>NullPointerException</code> when I check if the <code>HashMap</code> contains the key. In particular, in the <code>getEventSpeed()</code> method.</p>
  
  <p><code>.containsKey()</code> should return NULL, so not clear how this line causes issue for the if statement? </p>
  
  <p>Thank you for your help</p>
  
  <pre><code>public class IsDrivingObservation {
  
    private Map&lt;String,String&gt; observationMap;
  
    public String getEventSpeed() {
      if (observationMap.containsKey("eventSpeed")) {
        return observationMap.get("eventSpeed");
      }
      return "foo";
    }
  
    public void setEventSpeed(String speed) {
      observationMap.put("eventSpeed", speed);
    }
  
  }
  </code></pre>