Explanation
java.lang.String.charAt () method returns the char value at the specified index. The index range is from 0 to length () - 1. For the index of the array, the first sequence is a char value at index 0, the index 1, and so on
statement
public char charAt(int index)
parameter
index - This is the value of the index char
return value
This method returns the char value at the specified index of the string. Char index of the first value is zero.
abnormal
An IndexOutOfBoundsException - if the index argument is negative or not less than the length of the string.
Examples
public class Test { public static void main(String[] args) { String s ="abc"; System.out.println(s.charAt(2)); } }
Operating results are:
c