Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript
communitycreator

What is charAt() in JavaScript?

Mahnoor Zaheer

The charAt() method in Java returns a string character from a specified index.

Syntax

The syntax of this method is as follows:


string.charAt(index)

Parameters

The charAt() function takes one integer parameter that is the index from which the character needs to be extracted.

Return value

The return value is a character from the specified index.

Code

In the code below, the character E is extracted from the string s with the help of the charAt() method.

// extacting the character from 11th index of the string
class string {
    public static void main( String args[] ) {
        String s = "Welcome to Educative";
        char ch = s.charAt(11);
        System.out.println(ch); 
    }
}
The code example of the charAt() method in Java

RELATED TAGS

javascript
communitycreator
RELATED COURSES

View all Courses

Keep Exploring