Java String codePointAt() Method Example

The java.lang.String.codePointAt() method returns the character (Unicode code point) at the specified index. The index refers to char values (Unicode code units) and ranges from 0 to length() - 1.

This method throws the  IndexOutOfBoundsException  - if the index argument is negative or not less than the length of this string.

Java String codePointAt() Method Example

public class CodePointAtExample {
    public static void main(String[] args) {
        String str = "javaguides";
        int unicode = str.codePointAt(0);
        System.out.println("the character (Unicode code point) at the specified index is :: " + unicode);
    }
}

Output:
the character (Unicode code point) at the specified index is:: 106 

Reference



Comments