What is char charAt (int index) in Java, and how can I use it?
Java String charAt() method
public char charAt(int index)
Parameter:
index- Index of the character to be returned.
Return:
returns character at the specified position.
Exception:
StringIndexOutOfBoundsException- If index is negative or greater then the length of the String.
Example:To show working of charAt() method
The Java String charAt() method returns the character at the specified index. The index value should lie between 0 and length()-1.
Signature:public char charAt(int index)
Parameter:
index- Index of the character to be returned.
Return:
returns character at the specified position.
Exception:
StringIndexOutOfBoundsException- If index is negative or greater then the length of the String.
Example:To show working of charAt() method
Comments
Post a Comment