aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How many String objects created Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How many String objects created" Watch "How many String objects created" New topic
Author

How many String objects created

allison craig
Greenhorn

Joined: Dec 19, 2003
Posts: 17
String str = new String("zyx");

Yeah, yeah, I know everybody knows this.

Is it two, one for the 'new String' and the other "zyx"?
Is there a way check the actual number of Strings created?
[ January 20, 2004: Message edited by: allison craig ]
Vin Kris
Ranch Hand

Joined: Jun 17, 2002
Posts: 154
Just as you guessed, 2 String objects. A String literal "zyx" and a String object. Latter is eligible for GC and the former isn't.
allison craig
Greenhorn

Joined: Dec 19, 2003
Posts: 17
Thanks Vin. I'm going to pretend I can read opcodes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How many String objects created
 
Similar Threads
String literals??
Help: Basics of Thread
copying directories thru java code
Are string literals garbage collected?
How many objects are Garbage collected.Explain