| Author |
String Buffer
|
adbob adbob
Greenhorn
Joined: Dec 26, 2002
Posts: 1
|
|
Hi any can help me to know how it is printing only 'ABCDEFG' for the below question. class M{ public static void main (String[] args) { StringBuffer s1 = new StringBuffer(); s1.ensureCapacity(16); s1.append("ABCDEFG"); s1.setLength(35); System.out.print(s1 + "," + s1.capacity()); } } Thanks in Advance
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
My old Zen Master asked me once: "What is the appearence of a null character printing?" Thankyou for giving me one more opportunity to read the API for StringBuffer. -Barry [ January 02, 2003: Message edited by: Barry Gaunt ]
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Rene Larsen
Ranch Hand
Joined: Oct 12, 2001
Posts: 1179
|
|
When I run the program, the output is: Rene
|
Regards, Rene Larsen
Dropbox Invite
|
 |
 |
|
|
subject: String Buffer
|
|
|