title: Why can't you call a method on a null pointer in Java?
body: <p>In Go, it is OK to call a method on a null pointer so long as that pointer is never dereferenced:</p>
  
  <pre class="lang-go prettyprint-override"><code>type empty struct{}
  func (e *empty) Allocated() bool { return e != nil }
  </code></pre>
  
  <p>(For runnable code, click <a href="http://play.golang.org/p/y7QHshrU30">here</a>)</p>
  
  <p>In Java, however, calling a method on a null pointer, even if the method never dereferences any member variables, still causes a null pointer exception:</p>
  
  <pre class="lang-java prettyprint-override"><code>class Test {
      public boolean Allocated() { return this != null; }
  }
  </code></pre>
  
  <p>Does anybody know why this behavior exists? Is there some advantage that it gives? Thoughts?</p>