> Yes java String can hold upto 4 GB. But this also
> depends on the memory you have configured on your
> machine.
If anyone else is reading the above nonsense, ignore it. It's, well, nonsense. The JLS does not mandate an upper limit on the size of Strings, but in common actual implementations of Java, Strings are composed of arrays of characters, and an array can contain at most 2147483647 (Integer.MAX_VALUE) elements, which falls some way short of 4GB
> If anyone else is reading the above nonsense, ignore
> it. It's, well, nonsense. The JLS does not mandate an
> upper limit on the size of Strings, but in common
> actual implementations of Java, Strings are composed
> of arrays of characters, and an array can contain at
> most 2147483647 (Integer.MAX_VALUE) elements, which
> falls some way short of 4GB
...at 2 bytes per character = 4Gb!
;-)
> > If anyone else is reading the above nonsense,
> ignore
> > it. It's, well, nonsense. The JLS does not mandate
> an
> > upper limit on the size of Strings, but in common
> > actual implementations of Java, Strings are
> composed
> > of arrays of characters, and an array can contain
> at
> > most 2147483647 (Integer.MAX_VALUE) elements,
> which
> > falls some way short of 4GB
>
> ...at 2 bytes per character = 4Gb!
>
> ;-)
Doh! I'm invoking the "it's Monday and I had 2 hours sleep after seeing Aerosmith last night" rule :-)
Although still the JLS doesn't actually mandate the limit