title: Java Different between String s1 = "abc" and String s1 = new String("abc")?
body: <p>I am reading some notes about how to compare equality between String in Java. </p>
  
  <pre><code>String s1 = new String("abc");
  String s2 = new String("abc");
  </code></pre>
  
  <p>These two are allocated in different memory, so their reference are different. 
  When we call </p>
  
  <pre><code>if (s1 == s2){ .. } // Comparing the reference, so return false
  if(s1.equal(s2)){..} // Comparing content, so return true
  </code></pre>
  
  <p>So, what is</p>
  
  <p><code>String s3 = "abc"</code>
  <code>String s4 = "abc"</code>?</p>
  
  <p>How is the memory allocated and when I do different equality check, what will happen? </p>
  
  <p>For example :</p>
  
  <pre><code>s3==s4
  s3.equal(s4)
  s3.equal(s1)
  </code></pre>