Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
Programmer Certification (OCPJP)
How many String objects created
allison craig
Greenhorn
Posts: 17
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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
Posts: 154
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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.
Method void main(java.lang.String[]) 0 new #2 <Class java.lang.String> 3 dup 4 ldc #3 <String "zyx"> 6 invokespecial #4 <Method java.lang.String(java.lang.String)> 9 astore_1 10 return
allison craig
Greenhorn
Posts: 17
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks Vin. I'm going to pretend I can read opcodes.
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Help: Basics of Thread
String literals??
copying directories thru java code
How many objects are Garbage collected.Explain
Are string literals garbage collected?
More...