Creating New Strings
Earlier we promised to talk more about the subtle differences between the various
methods of creating a String. Let�s look at a couple of examples of how a String might
be created, and let�s further assume that no other String objects exist in the pool:
1 � String s = "abc"; // creates one String object and one reference
In this simple case, �abc� will go in the pool and s will refer to it.
2 � String s = new String("abc"); // creates two objects, and one
// reference variable
In this case, because we used the new keyword, Java will create a new String
object in normal (nonpool) memory, and s will refer to it. In addition, the literal
�abc� will be placed in the pool.
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Free, earth friendly heat - from the CodeRanch trailbosshttps://www.kickstarter.com/projects/paulwheaton/free-heat