title: Why does String.valueOf(null) throw a NullPointerException?
body: <p>according to the documentation, the method <a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html#valueOf(java.lang.Object)" rel="noreferrer"><code>String.valueOf(Object obj)</code></a> returns:</p>
  
  <blockquote>
    <p>if the argument is <code>null</code>, then a string equal to <code>"null"</code>; otherwise, the value of <code>obj.toString()</code> is returned.</p>
  </blockquote>
  
  <p>But how come when I try do this:</p>
  
  <pre><code>System.out.println("String.valueOf(null) = " + String.valueOf(null));
  </code></pre>
  
  <p>it throws NPE instead? (try it yourself if you don't believe!)</p>
  
  <pre>
      Exception in thread "main" java.lang.NullPointerException
      at java.lang.String.(Unknown Source)
      at java.lang.String.valueOf(Unknown Source)
  </pre>
  
  <p>How come this is happening? Is the documentation lying to me? Is this a major bug in Java?</p>