Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Number of string objects being created

 
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
Pie
Posts: 3918
10
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