aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Please clarify on number of strings 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 "Please clarify on number of strings" Watch "Please clarify on number of strings" New topic
Author

Please clarify on number of strings

Kunal Kumar
Greenhorn

Joined: Dec 05, 2006
Posts: 3
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

Joined: Jan 10, 2007
Posts: 122
Iirc a part of the question was "prior to the println()-statement".
Kunal Kumar
Greenhorn

Joined: Dec 05, 2006
Posts: 3
Oh!!

Thanks for clarification!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please clarify on number of strings