title: Why explicitly throw a NullPointerException rather than letting it happen naturally?
body: <p>When reading JDK source code, I find it common that the author will check the parameters if they are null and then throw new NullPointerException() manually.
  Why do they do it? I think there's no need to do so since it will throw new NullPointerException() when it calls any method. (Here is some source code of HashMap, for instance :)</p>
  
  <pre><code>public V computeIfPresent(K key,
                            BiFunction&lt;? super K, ? super V, ? extends V&gt; remappingFunction) {
      if (remappingFunction == null)
          throw new NullPointerException();
      Node&lt;K,V&gt; e; V oldValue;
      int hash = hash(key);
      if ((e = getNode(hash, key)) != null &amp;&amp;
          (oldValue = e.value) != null) {
          V v = remappingFunction.apply(key, oldValue);
          if (v != null) {
              e.value = v;
              afterNodeAccess(e);
              return v;
          }
          else
              removeNode(hash, key, null, false, true);
      }
      return null;
  }
  </code></pre>