java.lang.Character highSurrogate(int codePoint)


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:

Character.highSurrogate(int codePoint)

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.


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.


 * This example source code demonstrates the use of 
 * highSurrogate(int codePoint) method of Character class.

public class CharacterHighSurrogateExample {

	public static void main(String[] args) {
		// initialize codepoints
		int codepoint1 = 65808;
		int codepoint2 = 15672;
		// get the leading surrogate 
		char result1 = Character.highSurrogate(codepoint1);
		char result2 = Character.highSurrogate(codepoint2);
		// print the result
		System.out.println("The leading surrogate of "+codepoint1 +
				" is "+result1);
		System.out.println("The leading surrogate of "+codepoint2 +
				" is "+result2);



Sample Output

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

java Character highSurrogate(int codePoint) example output