JavaStringcharAt

Returns the character at the specified index.

Syntax

str.charAt(index)

Example

Enter values below to update the example in real time.

String
System
out
println
charAt
String s = "Hello";
System.out.println(s.charAt(0));  // 'H'
System.out.println(s.charAt(4));  // 'o'