title: JVM strings stored in memory
body: <p>What is the difference (memory-wise) between</p>
  
  <pre><code>private static final String FAILURE_MESSAGE=    "...";
  
  protected String getFailedMsg() {
      return FAILURE_MESSAGE;
  }
  </code></pre>
  
  <p>And</p>
  
  <pre><code>protected String getFailedMsg() {
      return "...";
  }
  </code></pre>
  
  <p>Assuming that the <code>FAILURE_MESSAGE</code> is only referenced from the above function. </p>
  
  <p>I mean where and how are the above objects/strings being held in memory in the above cases? 
  Is it JVM specific? </p>
  
  <p>Edit: I know that the string is interned in the first approach, but where is it value being stored/held/(interned?) in the second approach before the function is called? </p>
  
  <p>Second edit as an afterthought - what if the strings are replaced with ints or some other class that is not a string?</p>