StringBuilder constructor implementation vulnerable to exception

Viewed 288

The initial capacity of a StringBuilder when initialized with an existing String or CharSequence is the length of the original text + 16 from the code in StringBuilder constructor:

super(str.length() + 16);

My query what if the original length is close to Integer.MAX_VALUE ?

Will it throw NegativeArraySizeExceptionor will it change int to long for proper execution ?

3 Answers
Related