title: strange behavior of == in Java
body: <p>I observed a strange behavior <code>==</code> operator in java. I am trying to print the out put as follows</p>
  
  <pre><code>String str1 = "Rajesh";
  String str2 = "Rajesh";
  System.out.println("Using equals() str1 and str2 Equals :"
              + str1.equals(str2));
  System.out.println("Using == str1 and str2 Equals :" 
              + str1 == str2);
  </code></pre>
  
  <p>The first SOP statement printing </p>
  
  <blockquote>
    <p>Using equals() str1 and str2 Equals :true</p>
  </blockquote>
  
  <p>and the next SOP printing only false .</p>
  
  <p>I tried compiling in both eclipse and Net Beans but result is the same .
  I am so confused why</p>
  
  <blockquote>
    <p>Using == str1 and str2 Equals :</p>
  </blockquote>
  
  <p>is not printing</p>
  
  <p>Help me out in this </p>
  
  <p>Thanks in advance,</p>
  
  <p>Raj</p>