Vince Botteman wrote:The explanation starts with the sentence "Line 6 returns the number 3 since indexes are zero based." The index of number 6 in the string is 2 and not 3.
You are correct!

Should definitely be
Line 6 returns the number 2 since indexes are zero based. The remainder of the explanation is spot-on:
total has a value of 6 (2 + 4) and
charAt(4) will throw a StringIndexOutOfBoundsException.