title: String Scope : regular heap vs pool
body: <p>I know how String pool works and all. That said:</p>
  
  <pre><code>void doSomething1(){
   System.out.println("This string is now added to the string pool and will stay there even after this method returns");
  }
  
  void doSomething2(){
   String msg = new String("This string is now added to the string pool and will stay there even after this method returns");
  
   System.out.println(msg);
  }
  </code></pre>
  
  <p>Is <code>doSomething2</code> better than <code>doSomething1</code>. Should this be encouraged, given that some Strings have a very low chance of being <code>reused</code>. The problem I see is in case 1, the string stays in scope for extended period even when it is not used again.</p>