Java string get char at index

Java String charAt() Method

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

The index of the first character is 0, the second character is 1, and so on.

Syntax

public char charAt(int index) 

Parameter Values

Technical Details

Returns: A char value at the specified index of this string.
The first char value is at index 0
Throws: IndexOutOfBoundsException — if index is negative or not less than the length of the specified string

❮ String Methods

Unlock Full Access 50% off

COLOR PICKER

colorpicker

Join our Bootcamp!

Report Error

If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:

Thank You For Helping Us!

Your message has been sent to W3Schools.

Top Tutorials
Top References
Top Examples
Get Certified

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Источник

Читайте также:  System date format java
Оцените статью