Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String declaration

 
sriramaraju vysyaraju
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String str="sri"+"rama"+"raju";
How many String objects are created in the above statement?
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's your guessed ? What you think ? If you don't have knowledge about String constant pool , Googled It !
 
Campbell Ritchie
Sheriff
Posts: 48445
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sriramaraju vysyaraju:
String str="sri"+"rama"+"raju";
How many String objects are created in the above statement?
97. And you might find something about the constant pools on the BCEL website; look at �2 and �3.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic