I mean when s1 is concatenated by fall...then its value will be "spring fall"....
Ruben Soto wrote:
String s = "Text"; // 1
String s = new String("Text"); // 2
Case 1: Look in the SCP to see if there is a reference to "Text" (a String object that already exists in the heap with that content.) If there is one, assign that reference to s. If there is not one, create a new String object with the contents "Text" in the heap, create a new reference in the SCP referring to that object, and assign that reference to s as well (so both the SCP reference and s (the reference in your code) point to the same object in the heap.)
Loading of a class or interface that contains a String literal (§3.10.5) may create a new String object to represent that literal. (This might
not occur if the same String has previously been interned (§3.10.5).)