I have a string that goes like "abcdefg..."
I would like to find the index where the letter d is at, so I can get the number 3.
I managed to do it by looping through each letter in the string, but that doesn’t sound very convenient. Is there another way?
The
Stringclass exposes some methods to enable this, such asIndexOfandLastIndexOf, so that you may do this: