Curriculum
Course: Java Basic
Login

Curriculum

Java Basic

Java Home

0/1

Java Introduction

0/1

Java Get Started

0/1

Java Syntax

0/1

Java Comments

0/1

Java Type Casting

0/1

Java Operators

0/1

Java Booleans

0/1

Java Switch

0/1

Java Break / Continue

0/1

Java Errors and Exception

0/1
Text lesson

codePointAt()

Example

Retrieve the Unicode value of the initial character in a string (e.g., the Unicode value of “H” is 72).

String myStr = "Hello";
int result = myStr.codePointAt(0);
System.out.println(result);

Definition and Usage

The codePointAt() method retrieves the Unicode value of the character located at a specified index within a string. In this string, the first character’s index is 0, the second character’s index is 1, and so forth.

Syntax

public int codePointAt(int index)

Parameter Values

Parameter 

Description

index

An integer value that represents the index of the character you want to retrieve.

Technical Details

Returns:

An integer value that signifies the Unicode value of the character located at the specified index.

Throws:

IndexOutOfBoundsException occurs if the index is either negative or exceeds the length of the specified string.

Java Version:

1.5