java.lang.Character highSurrogate(int codePoint)

Description

The Character.highSurrogate(int codePoint) java 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. If the specified character is not a supplementary character, an unspecified char is returned.

If isSupplementaryCodePoint(x) is true, then isHighSurrogate(highSurrogate(x)) and toCodePoint(highSurrogate(x), lowSurrogate(x)) == x are also always true.

The highSurrogate(int codePoint) method of Character class is static thus it should be accessed statically which means the we would be calling this method in this format:

Non static method is usually called by just declaring method_name(argument) however in this case since the method is static, it should be called by appending the class name as suffix. We will be encountering a compilation problem if we call the java highSurrogate() method non statically.

Method Syntax

public static char highSurrogate(int codePoint)

Method Argument

Data Type Parameter Description
int codePoint a supplementary character (Unicode code point)

Method Returns

The highSurrogate(int codePoint) method of Character class returns a char datatype which denotes the leading surrogate code unit used to represent the character in the UTF-16 encoding.

Compatibility

Requires Java 1.7 and up

Java Character highSurrogate(int codePoint) Example

Below is a simple java example on the usage of highSurrogate(int codePoint) method of Character class.

Sample Output

Below is the sample output when you run the above example.

java Character highSurrogate(int codePoint) example output