The string is a sequence of characters. Each character in a string has an index which specifies its position in the string. The index of the first character is 0, the second character is 1, and so on.The character at the nth position has the index n.