This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Originally posted by Deepak Bajoria: How many String objects will be created when this method is invoked?
As per my understanding string object created would be: "Fred", "47", "Fred47" "ed4" "ED4"
Please correct me if wrong
Sandeep, Are you completely sure?
Because ther has been a lot of discussion on this question (That's another thing that I still don't remember the correct answer!)
But as far as i remember.. I remember some one mentioning that this question asks "when this method is invoked" And "47" is created in the pool during compile time, so in that case "47" won't be included in the list of String created.
I belive there are 4 Strings that are created.
Some one correct if I am wrong. [ July 21, 2008: Message edited by: Nabila Mohammad ]
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Joined: Nov 05, 2007
Looks like there are 3 Strings created when the method is invoked.
"Fred" and "47" are String literals which are created when the class is loaded.