Java Data Type Tutorial - Java String.charAt(int index)








Syntax

String.charAt(int index) has the following syntax.

public char charAt(int index)

Example

In the following code shows how to use String.charAt(int index) method.

public class Main {
  public static void main(String args[]) {
    String strOb1 = "java2s.com";

    System.out.println("Char at index 3 in strOb1: " + strOb1.charAt(3));


  }
}

The code above generates the following result.