What is the maximum size of a String object in java ?

Question : What is the maximum size of a String object in java ?

Answer :

There is no explicit maximum, but the String API won’t support Strings
longer than Integer.MAX_VALUE (in excess of two billion) characters.
Since characters are two bytes in size, a maximal String would require
more than 4GB of storage. A 32-bit computer cannot even address enough
space for such a behemoth. (It could barely address all the characters,
but not the object overhead. And it couldn’t at the same time address
such trivialities as, say, the operating system kernel.) Thus in
practice, you will run into other limits long before you hit the
hypothetical maximum String size.

All of that is beside the point however. Note well: *anything you are
contemplating that would make use of very large Strings is a BAD IDEA*.
I say that with confidence despite having no other information about
your plan.

ref: http://www.velocityreviews.com/forums/t141739-max-length-of-a-string.html


About Firat Karakusoglu

IIT Tech.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: