title: what must be hashcode of null objects in Java?
body: <p>According to a comment from this <a href="https://stackoverflow.com/questions/11184041/how-is-hashcode-calculated-for-null-object">post</a>, <code>hascode</code> of <code>null objects</code> can <code>throw NPE</code> or a value of <code>zero</code>. This is implementation specific. but within the same implementation, why does 
  <code>Objects.hashcode</code> and <code>hascode(instance)</code> return different values. for ex:</p>
  
  <pre><code>public class EqualsTesting {
  
      public static void main(String[] args){
          String p1 =null;
          String p2 = null;
          System.out.println(Objects.hashCode(p1));
          System.out.println(p2.hashCode());
  
      }
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>0
  Exception in thread "main" java.lang.NullPointerException
      at BinaryTrees.EqualsTesting.main(EqualsTesting.java:14)
  </code></pre>
  
  <p>If this is the case, will this not affect the <code>key look-up</code> in <code>HashMap</code> where <code>null Key-value pairs</code> are allowed. (It might either <code>hash</code> to <code>bucket 0</code> or <code>throw a NPE</code>)</p>