The following are mock exam (www.theglobe.com)questions:
1.
String str5 = new String("amit"); //line 1
String str7 = "arit"; //line 2
String str6 = str5.replace('m','r'); //line 3
System.out.println(str6 == str7);
The answer is false. I am confused because I think the string "arit" at line 2 in the string pool is the same one created at line 3. Please help!
2.
String s1 = "ab";
String s2 = "abcd";
String s3 = "cd";
String s4 = s1+s3;
s1 = s4;
if (s1 == s2) System.out.println("s1 == s2");
Again, the anwser is false. I think the concept in question 2 is similar to that of question 1. I am stuck on the same wrong concept. Need help.