Doubt of String Buffer for Vicken Karaoghlanian & others
posted 12 years ago
hi friends, ( posted August 28, 2003 03:34 AM by Vicken Karaoghlanian ) this thread was posted by Vicken , what is the solution to this problem ?
1) on line 2, a string buffer (s) of capacity 16 + 5 = 21 is created. 2) on line 3, we appended ss to s making 16 + 5 = 21, which fits perfectly in s, making the output on line 4 equals to 21. my question is: if we add another character to ss
the output (capcity) of s becomes 44 !!! isn't suppose that the capacity increases by one, hence becoming 22?? -------------------- [ Jess adjusted the code and added UBB [code] tags to make it readable and to preserve the whitespace, check 'em out! ] [ October 09, 2003: Message edited by: Jessica Sant ]
"The man who can drive himself further once the effort gets painful is the man who will win." <br />Roger Bannister
public void ensureCapacity(int�minimumCapacity) Ensures that the capacity of the buffer is at least equal to the specified minimum. If the current capacity of this string buffer is less than the argument, then a new internal buffer is allocated with greater capacity. The new capacity is the larger of: * The minimumCapacity argument. * Twice the old capacity, plus 2. If the minimumCapacity argument is nonpositive, this method takes no action and simply returns