Java String Method charAt()

This method takes one integer argument and return a character specified at index position. For any string the index value starts from 0 to string length -1 position. If passed index value not in valid range then it throws IndexOutOfBoundsException.

For example string Hello Friends contains 13 characters starting from 0 to 12 H is first position with index value 0, F is in seventh position with index value 6 and s is in 13 position with index value 12.
Using numbre other then 0 to 12( 0 to length()-1) will result in IndexOutOfBountException


public char charAt(int index)


index -Integer index value to get character at specified index position.


Character at passed index value.

Exception Throws:

IndexOutOfBoundsException If index value in not between 0 to String length()-1



Now Print all characters with its index value