This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Please clarify on number of strings  RSS feed

 
Kunal Kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Consider the following code snippet from K&B (Chapter 6)



The book says - There were a total of eight String objects created as follows: "spring", "summer " (lost), "spring summer", "fall" (lost), "spring fall" (lost), "spring summer spring" (lost), "winter" (lost), "spring winter" (at this point "spring" is lost).

My Question is - Why are we missing an string ( which is embedded in print statement, i.e., " ") while counting the number of string objects? This *SPACE* string ( " " ) is also an string objects created in string pool. so the number of string object created should be 9. Please confirm!

Thanks!
[ February 08, 2007: Message edited by: Barry Gaunt ]
 
Anton Uwe
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iirc a part of the question was "prior to the println()-statement".
 
Kunal Kumar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh!!

Thanks for clarification!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!