| Author |
How many string objects
|
Sneha Kapoor
Ranch Hand
Joined: Jun 08, 2009
Posts: 49
|
|
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
Joined: Mar 24, 2008
Posts: 3670
|
|
|
Please QuoteYourSources. Simple search for "fred 47" in the forum will give you the answer for this.
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
Sneha Kapoor
Ranch Hand
Joined: Jun 08, 2009
Posts: 49
|
|
|
Source: VoodooExam
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3670
|
|
|
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).
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
Look here
http://www.coderanch.com/t/434127/Programmer-Certification-SCJP/certification/many-String-Objects-are-created#1930019
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
 |
|
|
subject: How many string objects
|
|
|