String s1=new String("amit");
System.out.println(s1.replace('m','r'));
System.out.println(s1);
String s3 = "arit";
String s4 = "arit";
String s2 = s1.replace('m','r');
System.out.println(s2 == s3);
System.out.println(s3 == s4);
My answer is arit amit true true , but the answer is arit amit false true.
What I understood is s2,s3 and s4 points to the same memory area. Anybody can explain me these memory area in detail ?