If I want to create a String object which contains x number of character, where x > Integer.MAX_VALUE, can I do that?
Thanks.
Have a look at the source.
the field count
, which indicates the string's size is an int
- so you will get an overflow.
private final int count;
Instead of storing a single String of length 2 bn (This will use 8 GB of memory to create btw) You can create a collection of Strings. Its not as easy to work with but can effectively be any length.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With