All code in my posts, unless a source is explicitly mentioned, is my own.
All code in my posts, unless a source is explicitly mentioned, is my own.
Thanks,
Alps
I mean when s1 is concatenated by fall...then its value will be "spring fall"....
Thanks,
Alps
SCJP 6
Ruben Soto wrote:
*snip*
String s = "Text"; // 1
and
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.)
*snip*
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).)
Java hobbyist.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Don't get me started about those stupid light bulbs. |