How many characters can a String have?
December 2, 2022
Since String.length()
method returns an int
we could guess that the maximum length would be Integer.MAX_VALUE
characters. That’s not correct. Let’s forget about Unicode for now, and try to create the longest possible string by repeating a lowercase letter a.