| Author |
String objects
|
Mohan Rayapuvari
Greenhorn
Joined: Jan 17, 2007
Posts: 7
|
|
Hi, String x = new String("xyz"); Above line , creates one string object with value "xyz" and assigns reference to x. But in kathy , it is given that 2 objects get created. Could anyone please confirm this. Txs & Rgs, Mohan
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Welcome to JavaRanch! See Strings, Literally, and let us know if this clears it up.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Javier Sanchez Cerrillo
Ranch Hand
Joined: Aug 02, 2006
Posts: 152
|
|
Yes, 2 objects are created: 1.- The object referenced by the variable. 2.- The object residing in the String constant pool.
|
SCJP 5.0 95%<br /> <br />The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge.
|
 |
Mohan Rayapuvari
Greenhorn
Joined: Jan 17, 2007
Posts: 7
|
|
|
Thanks for the response!!!
|
 |
 |
|
|
subject: String objects
|
|
|