| Author |
StringBuffer capacity
|
Vicken Karaoghlanian
Ranch Hand
Joined: Jul 21, 2003
Posts: 522
|
|
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??
|
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. <br />- What truth? <br />- That there is no spoon!!!
|
 |
Miki Muzsi
Ranch Hand
Joined: Jun 23, 2003
Posts: 120
|
|
when using append() for a StringBuffer, the ensureCapacity() method is implicitly called. See JLS1 - StringBuffer Miki
|
Miki<br /> <br />SCJP 1.4, SCBCD 1.3
|
 |
 |
|
|
subject: StringBuffer capacity
|
|
|