Loops over a String

A loop over the indices 0 to length() minus 1 visits each character with substring(i, i + 1), which is how we count, find, reverse or rebuild text, and stopping one too late runs off the end of the String.

From AP Computer Science A.