File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes String Buffer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "String Buffer" Watch "String Buffer" New topic

String Buffer

adbob adbob

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();
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.
[ 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:


Regards, Rene Larsen
Dropbox Invite
I agree. Here's the link:
subject: String Buffer
It's not a secret anymore!