What is the output? For extra credit, how many String objects and how many
reference variables were created prior to the println statement?
Answer: The result of this code fragment is "spring winter spring summer". There
are two reference variables, s1 and s2. There were a total of eight String objects
created as follows: "spring", "summer " (lost), "spring summer", "fall" (lost), "spring
fall" (lost), "spring summer spring" (lost), "winter" (lost), "spring winter" (at this point
"spring" is lost). Only two of the eight String objects are not lost in this process.
I think the Answer: is incorrect, There are a total of
nine String objects created as
follows: "spring " (lost), "summer " (lost), "spring summer ", "fall " (lost), "spring fall " (lost),
"spring summer spring " (lost), "winter " (lost), "spring winter ", and
" " (lost).
Only two of the nine String objects are not lost in this process.
What do you think?