Max Java String Length

Page content

I was wondering about what would be the maximum String length in Java, and the funny thing is that Java’s Strings are Arrays that are indexed by int.

So the maximum String length is

2^31 - 1

And this is true for any Java Array: