title: Garbage collection of String literals
body: <p>I am reading about Garbage collection and i am getting confusing search results when i search for String literal garbage collections.</p>
  
  <p>I need clarification on following points:</p>
  
  <ol>
  <li><p>If a string is defined as literal at compile time [e.g: <code>String str = "java"</code>] then will it be garbage collected?</p></li>
  <li><p>If  use intern method [e.g: <code>String str = new String("java").intern()</code>] then will it be garbage collected? Also will it be treated differently from String literal in point 1.</p></li>
  <li><p>Some places it is mentioned that literals will be garbage collected only when <code>String</code> class will be unloaded? Does it make sense because I don't think <code>String</code> class will ever be unloaded.</p></li>
  </ol>