size « StringBuffer « Java Data Type Q&A

1. StringBuffer/StringBuilder size in java

All, Why is it suggested that the size of the StringBuffer/StringBuilder object should be initialized to a size of 2^{1...n}(Though usually it would be > 64). What would be the advantage/optimization would ...

2. stringbuffer == jvm heap size

can any one tell me wat will happen when the stringbuffer size is equal to jvm heap size, and when will we get outofmemory exception when we use stringbuffer variable, recently I got this exception coz my data is huge means 512mb. Than wat shuld I do, I can't change input data, how culd I overcome it.

3. Initial Size of StringBuffer - Primenumber??

I can't think of any reason why you'd ever want to use a prime number as the constructor argument to StringBuffer. If you're going to use a numeric argument, it should be your best guess as to the total size the StringBuffer will reach at a maximum, erring on the large side.

4. stringbuffer initial size

5. Why StringBuffer size is 16 charectors in java...?

ok .. so whatever is below applies for both StringBuilder and StringBuffer (since both are the same only that StringBuffer has synchronized methods) since Strings are immutable (cannot be changed), concatenating can be pretty time and memory consuming, since with every concatenation, the old version plus the String that needs to be appended are created as a new variable, having the ...

6. StringBuffer Size

7. max size of string ??? vs stringbuffer?