Hi,
Do u agree with the result of the following code:
class q1{
public static void main(
String args[]){
String s1=new String("jamit");
System.out.println(s1.replace('m','r'));
System.out.println(s1);
String s3="jarit";
String s4="jarit";
String s2=s1.replace('m','r');
System.out.println(s2==s3);
System.out.println(s3==s4);
System.out.println("\n\nNow reserch is here:");
System.out.println(s3.hashCode());
System.out.println(s4.hashCode());
System.out.println(s2.hashCode());
if(s2==s3)
System.out.println("s2==s3");
}
}
jarit
jamit
false
true
Now reserch is here:
100895878
100895878
100895878
bottom line is that why it is returning 'false' even the hashcodes are same.
Thanks in advance.