java.lang.Character highSurrogate(int codePoint)
Description
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.
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.
package com.javatutorialhq.java.examples; /* * 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.