title: will two strings with same content be stored in the same memory location?
body: <p>This is a question that I got in an interview.</p>
  
  <p>I've  two strings defined as </p>
  
  <pre><code>String s1="Java";
  String s2="Java";
  </code></pre>
  
  <p>My question is whether these two references point to the same memory location. In general, when we create identical strings (without new keyword), does the content get stored in the memory only once and all the String objects with the same content just refer to the same location, without storing the string "Java" redundantly ? The hash codes of s1 and s2 are the same. But are hashcodes dependent directly on memory location of the object? </p>