String pool
PremFeb 16 2011 — edited Feb 17 2011Hi
Consider following snippet of code
1. String s1="Hello";
2. String s2=new ("Hello");
3. String s3=new ("Hello");
4. SOP(s1==s2)
5. SOP(s2==s3)
Above line 4 and 5 returns false because s1 refers to a string in string pool where as s2 and s3 refers to string in heap .
I am having confusion on following code
1. String s1="Hello";
2. String s2=new ("Hello");
3. String s3=new ("Hello");
4. s1=s3;
i just want to know that s1 is now pointing to a string created into heap by s3.