String Indexing

H e l l o B o b
0 1 2 3 4 5 6 7 8
-9 -8 -7 -6 -5 -4 -3 -2 -1

Access the first character of a string

Access the first character and store it in a variable

Making Mistakes With Indexing

Negative Indexing

H e l l o B o b
0 1 2 3 4 5 6 7 8
-9 -8 -7 -6 -5 -4 -3 -2 -1

What if I wanted to access the last character of any arbitrary string? How would you do this? This involves calculating the length (the number of characters) in the string and finding an off for that.

What if we want some arbitrary position near the end of the string?