71.7k views
3 votes
If you know the maximum index of a string, what can you say about the maximum length of the string?

User Matty
by
6.8k points

1 Answer

5 votes
The length will be one more. If you have e.g., a string of length 3, the indices will be 0,1 and 2, with 2 being the maximum one. So the (maximum) length is always one more than the maximum index.
User SebastianStehle
by
6.7k points