Can someone please explain by this would only print , Equal B in the output ??? --------------------------------------------------- String s = new String( "Computer" );
sarimraza, if(s=="computer") will create a new string literal computer which does not have the same refernce value of s obtained from the statement String s = new String("computer"); You would know that == checks the object reference value and not the objects literal value. By reference i mean the address to which it points to. s == new String("computer") if(s == "computer") will create two different strings "computer" at different pleaces meaning at different memory addresses. So the address to which the object s is pointing to is not the same address at which the new string object "computer" is created in the line (s == "computer") which results in the comparision showing false. Hope this helps