public String makinStrings() {
String s = “Fred”;
s = s + “47”;
s = s.substring(2, 5);
s = s.toUpperCase();
return s.toString();
}
|
How many String objects will be created when this method is invoked?
Submitted by youngredrabbit on Wed, 2006-09-13 12:41.
public String makinStrings() { String s = “Fred”; s = s + “47”; s = s.substring(2, 5); s = s.toUpperCase(); return s.toString(); } |
User loginNavigationPartnersWho's new
Who's onlineThere are currently 0 users and 10 guests online.
|
|
|
Is this a quiz?
Is this a quiz?
if not, so take this note "String is immutable".
now you can count.
Ali Abdel-Aziz Ali
Software Engineer/OpenCraft
www.aliabdelaziz.com
are they five object or
are they five object or three?
I think they are 4.
I think they are 4.
Ali Abdel-Aziz Ali
Software Engineer/OpenCraft
www.aliabdelaziz.com
SCJP
It is one of the SCJP questions about the understanding of the String and StringBuffer objective.
The answer is 4
Ahmed Hashim
Software Engineer
hashimblog/