String Buffer defines three constructors. The default constructor reserves room for 16 characters without reallocation. The second version accepts an integer argument that explicitly sets the size of the buffer. The third version accepts a string argument that sets the initial contents of the string buffer object and reserves room for 16 more characters without reallocation. String buffer allocates room for 16 additional characters when no specific buffer length is requested, because reallocation is a costly process in terms of time. Also, frequent reallocation can fragment memory. By allocating room for a few extra characters, string buffer reduces the number of reallocation that take place.
Monday, December 29, 2008
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment