title: String comparison with logical operator in Java
body: <p>When comparing two strings, I was taught that we shouldn't use the logical operator (==). We should use String.equals(String) for the comparison. However, I see that the following code complies and prints "<code>Hello Friend</code>" with the latest JDK(1.6_23). I tried searching around and couldn't find any reference. From when is this happening?</p>
  
  <pre><code>public class StringComp{
  public static void main(String args[]){
          String s = "hello";
          if(s=="hello"){
                  System.out.println("Hello Friend");
          }else{
                  System.out.println("No Hello");
          }
      }
  }
  </code></pre>