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";
//w w  w  .  j a  va  2  s .  c o m
    System.out.println("Char at index 3 in strOb1: " + strOb1.charAt(3));


  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable