Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Number of string objects being created  RSS feed

 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In the following two cases, how many string objects are being created?



Thanks.
[ September 23, 2008: Message edited by: Arjun Reddy ]
 
Vijitha Kumara
Bartender
Posts: 3973
24
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) 1 object
2) 2 objects (one in the String constant pool if there is no matching one for "hey" and one in the heap)
 
Arjun Reddy
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Vijitha.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!