Java String.codePointAt()

The method codePointAt() takes an int as a parameter and returns the code point at the specified index. A code point is a decimal value that the character is given in the Unicode standard.

Available Signatures

[source,java,gutter:,false]

public int codePointAt(int index)

Example

[source,java,gutter:,true]

@Test
public void whenCallCodePointAt_thenDecimalUnicodeReturned() {
    assertEquals(97, "abcd".codePointAt(0));
}

Throws

* StringIndexOutOfBoundsException – if a non-existent index is passed to the method.

@Test(expected = StringIndexOutOfBoundsException.class)
public void whenPassNonExistingIndex_thenStringIndexOutOfBoundsExceptionThrown() {
    int a = "abcd".codePointAt(4);
}