G
gk
public class Test {
public static void main(String[] args) {
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);// why false ?
System.out.println(s3 == s4);
}
}
java support String pool...... s2 is created with the value "arit" and
so it should point to the same pool address.
whats happinh here ?
public static void main(String[] args) {
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);// why false ?
System.out.println(s3 == s4);
}
}
java support String pool...... s2 is created with the value "arit" and
so it should point to the same pool address.
whats happinh here ?