• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many String objects created

 
allison craig
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Vin. I'm going to pretend I can read opcodes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic