Java .codePointAt()

Anonymous contributor's avatar
Anonymous contributor
Published Jul 23, 2021Updated Sep 3, 2021
Contribute to Docs

Returns the Unicode value at the given index in the string.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours

Syntax

string.codePointAt(int index)
  • index (required): Integer value that represents the index of the Unicode value you want to retrieve.

Example 1

Print the Unicode value of the first character in the string "Hi":

String greeting = "Hi";
System.out.println(greeting.codePointAt(0));
// Output: 72

Example 2

Here’s a whole Java program that prints the Unicode value of the first character in the string "Hello World":

class FirstCharacterUnicodeValue {
public static void main(String[] args) {
String greeting = "Hello World";
System.out.println(greeting.codePointAt(0));
// Output: 72
}
}

All contributors

Contribute to Docs

Learn Java on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours