it has to be limited by Integer.MAX_VALUE as String's length() method returns int ... I had this similar discussion sometime back here and I remember Jim explained it to me but I can't find that thread right now... Regards Maulin
I believe a String's value is stored internally as a char array. Therefore, since you can't create a char array with a length > Integer.MAX_VALUE, a String must not be larger than Integer.MAX_VALUE.
Blake Minghelli<br />SCWCD<br /> <br />"I'd put a quote here but I'm a non-conformist"
Joined: Mar 11, 2004
Thats a pretty subjective reply. I am looking for an actual number.
Um, Integer.MAX_VALUE is an actual number. It's equal to 2147483647. Now in practice that requires about 4 GB of memory (each char takes 2 bytes), so you'll probably get an OutOfMemoryError before you create a String that big, unless you've got lots of available RAM and the JVM is configured to use it. But that's an environment-dependent limitation, not absolute. Integer.MAX_VALUE is a fundamental limitation - there's no way you can circumvent it.