If you go through with this link this may clear you more Oracle Docs String Builder Buffer Capacity
Now you want to declare the Capacity of any StringBuilder Class, then one Constructor StringBuilder(int initCapacity)
is defined for this.
StringBuilder(int initCapacity)
:- Creates an empty string builder with the specified initial capacity.
Here because of parameter as int
the maximum capacity that a StringBuilder
Class can is reach will be 2147483647
.
there are various method regarding this context of Capacity in StringBuilder
Class, those methods also consider the parameters of type int
.
void setLength(int newLength) :- Sets the length of the character sequence. If newLength is less than length(), the last characters in the character sequence are truncated. If newLength is greater than length(), null characters are added at the end of the character sequence.
void ensureCapacity(int minCapacity) :- Ensures that the capacity is at least equal to the specified minimum.
these methods also takes argument as of int
type . So, Using these methods or contructors you will able to generate a object with max capacity of 2147483647
.