title: What is the meaning of a String ID in Java?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2772763/why-equals-method-when-we-have-operator">why equals() method when we have == operator?</a>  </p>
  </blockquote>
  
  
  
  <p>When I tried executing the code in Java, it gave me 2 different outputs</p>
  
  <pre><code>String txt1="Hello";
  String txt2="Hello";
  System.out.println((boolean)txt1==txt2);
  
  String txt1=new String("Hello");
  String txt2=new String("Hello");
  System.out.println((boolean)txt1==txt2);
  </code></pre>