Max size for StringBuffer

前端 未结 4 1573
被撕碎了的回忆
被撕碎了的回忆 2020-12-17 02:56

Why would the StringBuffer have a limit on its size?

I went through some of the links : http://www.coderanch.com/t/540346/java/java/maximum-size-hold-S

4条回答
  •  渐次进展
    2020-12-17 03:44

    because stringbuffer internally uses an array and the maximum number of elements an array can accommodate is 2^31-1 if you increment after reaching this it will go to negative and throws the error

提交回复
热议问题