This method takes an index as a parameter and returns the character that is present at that index of the string. Indexing starts from zero. i. e index of 1st character is 0, 2nd character is 1 and so on. The index of the last character is the length of the string - 1.
CharAtString CODE class CharAt OUTPUT M DESCRIPTION At THINGS TO TRY
Another
String method, startsWith() , can be confused with the function of charAt (0). The difference lies in the result of either method: charAt(0) will return a character, whereas startsWith() is a test, returning a boolean .
|