author and iconoclast
posted 12 years ago
The length() method returns a signed integer, so that the largest length() value is 2GB. Internally, all the implementations of String I've looked at use an int to keep track of the number of characters, meaning that 2GB is a hard limit. Given that many Java implementations have a heap-size limit somewhat less that 2GB, this is not really a problem!