Java String charAt() Method

You are Here:

Java String charAt()

The charAt() method returns the character at the given index in a string.

The index number starts from 0 and goes to n-1, where n is length of the string.


Java Compiler
public class myClass { public static void main(String[] args) { String str = "Apple"; System.out.print(str.charAt(0)); // A } }




public char charAt(int index)

Parameter Values

indexRequiredSpecifies an index number.

Return Value

CharacterReturns the character at the given index in a string.
ErrorReturns StringIndexOutOfBoundsException, if index number is negative or not less than the length of the given string.


Hi Developers, we almost covered 90% of String functions and Interview Question on Java with examples for quick and easy learning.

We are working to cover every Single Concept in Java.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author