Hello
Java Gurus! I'm back at it with a question from reading the Java Language Specification 3.10.5:
String literals. Heres a code snippet from this topic (perhaps you have seen this at one time or another):
LINE A prints "true", LINE B prints "false".
Now the Java spec states the following (among others):
Quote 1:
Strings computed by constant expressions (�15.28) are computed at compile time and then treated as if they were literals.
and:
Quote 2:
Strings computed by concatenation at run time are newly created and therefore distinct.
My confusion is this: Is Quote 1 referring to LINE A in the code? I'm thinking that "Hel" and "lo" are the constant expressions the spec is referring to. Am I correct?
And: Is Quote 2 referring to LINE B in the code? Is "Hel" in LINE B newly created during run time because its concatenated to lo? If so, why isn't the same thing true for "Hel" and "lo" on LINE A?
Please straighten my tangled strings.
Thanks much.
g