A String
is an immutable character array.
A StringBuffer
is a mutable character array. Often converted back to String
when done mutating.
Since both are an array, the maximum size for both is equal to the maximum size of an integer, which is 2^31-1 (see JavaDoc, also check out the JavaDoc for both String
and StringBuffer
).This is because the .length
argument of an array is a primitive int
. (See Arrays).