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


public int codePointAt(int index)



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


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

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