public class MainDemo
{
public void comp()
{
String s1 = "abc";
String s2 = "abc";
System.out.print(""+s1==s2); // Why return false??? Plz clear my doubt?
System.out.println(s1==s2);//And why true for this
}
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
MainDemo obj=new MainDemo();
obj.comp();
}
}
#####################################################
Why this return false ??
System.out.print(""+s1==s2); // Why return false???
Please clear my doubt?
Edited
Can someone Tell me how do I check the instance Value
EDITED 2
System.out.println(s1.hashCode()); // BOTH ARE SAME
System.out.println(s2.hashCode());// BOTH ARE SAME
Then What happened to this?????