Character.highSurrogate() in Java

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

Syntax:

char java.lang.Character.highSurrogate(int codePoint)

This method takes one argument of type int as its parameter. This method returns the leading surrogate (a high surrogate code unit) of the surrogate pair representing the specified supplementary character (Unicode code point) in the UTF-16 encoding.

Note: If the specified character is not a supplementary character, an unspecified char is returned.

Parameters: One parameter is required for this method.

codePoint: a supplementary character (Unicode code point)

Returns: the leading surrogate code unit used to represent the character in the UTF-16 encoding.

Exceptions: NA (This method does not throw any exceptions).

Approach

Java

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

        int codePoint = '@';
        System.out.println(Character.highSurrogate(codePoint));
    }
}

Output:

No comments:

Post a Comment