Strings as Set of Characters

Let's practice few methods that access or iterate over a string.

Identifying a particular character

You may think of a string as an array of characters. Each character is identified by a number called an index, just as it does for an array. The same golden rules apply:

  • The index of the first character in a string is 00, not 11
  • The highest index number is the string’s length minus 11

Let’s have a look at the illustration below:

Get hands-on with 1400+ tech skills courses.