Max size for StringBuffer

前端 未结 4 1569
被撕碎了的回忆
被撕碎了的回忆 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:42

    StringBuffer uses a char[].
    In Java an array can be indexed only via an integer which means the highest value the index of the array can be is Integer.MAX_VALUE - 1 (i.e. 2^31 - 1). Which means that the size of an array in Java can not be larger than Integer.MAX_VALUE

提交回复
热议问题