aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String objects Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "String objects" Watch "String objects" New topic
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!!!
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: String objects
 
Similar Threads
string objects
Very Important String Questions
string function problem
number of objects created?
Hom many Objects are created ???