Assume you create a string variable str1, when this string is getting created inside the heap memory we have string pool, where your value will be stored as object. And then if you try to create a new string str2 with same value “RefreshScience”, str2 will get pointed to existing object. It won’t create another new object. JVM will check if the object exists, if it is not then it creates new object. Example: String str1 = “RefreshScience”; //object (101) String str2 = “RefreshScience”; //object (101) str1 points to object1, str2 also points to object1. If any new value is assigned to str1, a new object will be created and the value of str2 still points to existing object. Example: str1 = “RefreshScience.com”; //object (103)