title: Typecasting null in java
body: <p>When we are using <code>System.out.println(null)</code> then we get compilation error and to resolve this we typecast <code>null</code> like:</p>
  
  <pre><code>System.out.println((String)null) 
  </code></pre>
  
  <p>and then it starts working fine.</p>
  
  <p>My questions is how we are allowed to typecast <code>null</code> when we say that <code>null</code> is something which is not pointing to any location and thus has no value in itself.</p>
  
  <p>Also if null is not pointing to any location then the object which is null will get Garbage collected then why we are using it at first place? I know it is litle bit out of the topic but it came to my mind.</p>
  
  <p>I have seen few answers in below link but they mostly talk about println method functionality and implementation but I want to know about null only.</p>
  
  <p><a href="https://stackoverflow.com/questions/18723596/no-exception-while-type-casting-with-a-null-in-java">No Exception while type casting with a null in java</a></p>