.codePointBefore()

.codePointBefore()

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

Syntax

string.codePointBefore(index)
  • index (required): An int value that represents the Unicode value you want to retrieve for the element before the given index.

Example 1

Print the Unicode value of the first character, "H" at the first index:

class FirstCharacterUnicodeValue {
public static void main(String[] args) {
String greeting = "Hello World";
System.out.println(greeting.codePointBefore(1));
// Output: 72
}
}
Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Java on Codecademy