Yes, I agree, the text and appendix are misleading, but the code is correct.
It is in fact identical to substring, but a bit counter intuitive.
"Hello World".substring(0,4) = "Hell"
i.e. the first four items, exactly like in the example in the book.
You need to think of the index being positioned in the spaces between the letters, instead of referring to a specific letter for each index.
|