Java charAt() is an inbuilt method of string that helps us find the position of any character in the  string. The index that we have to put should be between 0 to (length_of_string – 1). For example, s.charAt(0) would return the first character of a string represented by instance s. Java String charAt method throws an IndexOutOfBoundsException if an index value passed in a charAt() method is less than 0 or greater than or equal to a length of the string (index<0|| index>=length()).

charAt() In Java Example

The java.lang.String.charAt() method returns a char value at a specified index. An index ranges from 0 to length() – 1. The first char value of a sequence is at index 0, the next at index 1, and so on, as for array indexing.

Syntax:

character = string_name.charAt(index_position)

So, there is one parameter in charAt() which is the index of string.

#charat #java string charat #java

charAt() In Java Example | Java String charAt() Method
1.85 GEEK