Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many string objects

 
Sneha Kapoor
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi All,




As per understanding there are 3 objects 1)Fred 2)47 3)s.toString(); on line 16

am i right??
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please QuoteYourSources. Simple search for "fred 47" in the forum will give you the answer for this.
 
Sneha Kapoor
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source: VoodooExam
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except toString() method all other operations will create a new object ( except s=s+"47" will make 2). For scjp level this is correct (as there are little more to this with regards to the String constants as they may have created already before the method invoked, at the class loading).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic