![]() |
VOOZH | about |
String charAt() method in Java returns the character at the specified index in a string. The Index of the first character in a string is 0, the second character is 1, and so on. The index value should lie between 0 and length() - 1.
If the index value is greater than or equal to the string length or negative number it returns stringIndexOutOfBoundsException
Example 1:
public char charAt(int index)Example 2: The following program demonstrating the Exception case as StringIndexOutOfBoundsException.
Example 3: Accessing the First and Last Character
Example 4: Print Characters Presented at Odd Positions and Even Positions
Example 5: Counting Frequency of a Character in a String