Same old Question please reply
Please don't get weird with the same old question. I am getting confusion in the string comparision.
I am trying to execute the following programme where i am getting doubt.
String s = new String("abcus");
String s1 = new String("abcus");
String s2 = new String("abcus");
String s3 = new String("abcus");
int sh = s.hashCode();
int s1h = s1.hashCode();
int s2h = s2.hashCode();
int s3h = s3.hashCode();
if(sh == s1h)
When I compiled the above code
if i try to compile with checking the hash code using "==" then it is giving every time
if i try to compile with checking the reference variable using "==" then it is giving as NOT EQUAL.
By the above output i understand that while checking with "==" it not only checks the HashCode it also compares other thing.
I tried to get the actual implementation of Equals method and "==" but not able to find :(
Could you please let me know the reason behind the above checking and it would be great if I get the url for actual implementation of the above code.
Thanks in advance to all.