title: How duplicate Strings are stored which are created with new() but as a literal in Java?
body: <pre><code>String Str1= new String("java");  
  String Str3 = new String("java");
  
  System.out.println(Str1==Str3);
  </code></pre>
  
  <p>The 1st line of code creates object <code>str1</code> with content <code>"java"</code> init both in <code>String</code> pool and heap. Now what will <code>Str3</code> does? I know it create <code>Str3</code> in heap what about <code>Str3</code> in String pool? What does 3rd line do? does it checks for equality in <code>String</code> pool or in heap area?  I know that it gives false but my question is if Str1 and Str3 are stored in String pool == should give true right as references are same.</p>