aspose file tools*
The moose likes Beginning Java and the fly likes When The default value of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "When The default value of "StringBuffer" is fill?" Watch "When The default value of "StringBuffer" is fill?" New topic
Author

When The default value of "StringBuffer" is fill?

Danish
Greenhorn

Joined: Mar 23, 2002
Posts: 3
Question :
When The default memory of
String buffre is fill and why Stringbuffer has default memory and when and why it is uesful for us .
plz reply as soon as possible
Thanksu


danish
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Danish,
Before I attempt to answer your question, let me say that you're probably going to have a bartender ask you to change your display name to a first and last name as per the naming policy here at JavaRanch.
Now, I'm not real sure what your asking about StringBuffer, but it is an extremely useful class. As you probably already know, String's are immutable. StringBuffers are essentially "mutable" Strings. As a matter of fact the JAVA platform uses StringBuffers behind the scenes to concatenate (add) Strings. For instance when you code something like this:

The compiler converts all of this into a StringBuffer, sticks the parts together and finally returns a String. You can do the same thing like this:

Hope this helps
Michael Morris
SCJP2


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Danish
Greenhorn

Joined: Mar 23, 2002
Posts: 3
HI
U DID NOT UNDERSTAND MY QUESTION;
my question is that the Stringbuffer has default more memory about 16 and if we create an object in stringbuffer will occupies memory
memory=object in stringbuffer + 16(default value of stringbuffer)
thanking for reply me and plz repiy me again to this question
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi again Danish,
Ok, let's take another crack at this. Are you asking why SUN in it's infinite wisdom decided to allocate a default buffer with a 16 char capacity?
If that's your question, I have no earthly, freakin' idea, but I suspect it went something like this:
System engineer dude 1:
"Hey Joe how may char's should the initial buffer in StringBuffer hold?"
System engineer dude 2:
"Gee Harry, I don't know. Let me do some performance testing and I'll get back with you on that."
.....
Two weeks later
System engineer dude 2:
"Hey Harry, I've got that data back on the initial buffer size for StringBuffers." It looks like somewhere around 13 characters gets the best performance."
System engineer dude 1:
"O, thanks Joe. What do you say we set it at 16 always best to use a power of 2 don't you think?"
System engineer dude 2:
"You bet. 13 would make us look like a bunch of Microsoft engineers."
I hope that answers your question.
Now if the default is a problem, you can set the initial buffer to whatever you want with:

Hope this helps :roll:
Michael Morris
SCJP2
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
Danish,

Before I attempt to answer your question, let me say that you're probably going to have a bartender ask you to change your display name to a first and last name as per the naming policy here at JavaRanch.

U DID NOT UNDERSTAND MY QUESTION

Did you understand Michael's statement? You were asked very politely to please change your display name. :roll:


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Danish
Greenhorn

Joined: Mar 23, 2002
Posts: 3
Thaku
you have been success to understand me about my stringbuffer thaku for that answer , if u dont mind then plz send the email address of u that i will contact u
my emailadress is "Danishnajam84@hotmail.com"
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Danish,
Hey dude, you really do need to change your display name to a first and last name before Marilyn sends a posse out after you and we have a lynchin' here at the Ranch.
Any way my email is:
mike@m2squared.com
If you look on my posts on this thread, there are several icons at the top. I think the third one is email. So if you want to get in touch with anyone here that posts that's where you'll find their emails.
Hope this helps
Michael Morris
SCJP2
[ March 24, 2002: Message edited by: Michael Morris ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: When The default value of "StringBuffer" is fill?
 
Similar Threads
OUTOFMEMORY Excep on tomcat
Mr. Bloch - Java "conductive to quality and prductivity, and a joy to work with"
StringBuffer Capacity
stringBuffer VS string
StringBuffer doubt