Character.toCodePoint() in Java

Character.toCodePoint(): This method is available in java.lang.Character class of Java.

Syntax:

int java.lang.Character.toCodePoint(char high, char low)

This method takes two arguments of type char as its parameters. This method converts the specified surrogate pair to its supplementary codepoint value.

Parameters: Two parameters are required for this method.

high: the high-surrogate code unit.

low: the low-surrogate code unit.

Returns: the supplementary code point composed from the specified surrogate pair.

Exceptions: NA

Approach

Java

public class CharactertoCodePoint {
    public static void main(String[] args) {

        char high = 'm', low = 'a';
        System.out.println(Character.toCodePoint(high, low));

    }
}

Output:

-56502175

No comments:

Post a Comment