Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Java charAt() Method

Java charAt() Method

Java String ClassJava String class


The charAt() method is used to return the character at the specified index. The index ranges from 0 to length() - 1.

Syntax


public char charAt(int index)

Parameters

Return Value

Returns the character at the specified index.

Example

Example

public

class

Test

{

public

static

void

main

(

String

args

[

]

)

{

String

s

=

"

www.runoob.com

"

;

char

result

=

s

.

charAt

(

6

)

;

System

.

out

.

println

(

result

)

;

}

}

The execution result of the above program is:


n

Java String ClassJava String class