posted 24 years ago
I think the three objects in the object heap are :
String s1,s2,s3,s4;
s1 = "Hello";
s2 = s1;----------------------------1
s3 = s2 + "Pal";--------------------2
s4 = s3;----------------------------3
From my understanding, there are only two conditions that an object will be pointed to the string pool
1. When we assigning a string literal to the String object
2. When we assigning String.valueOf(..) to the String object
Correct me if I am wrong.
KK.