Javatpoint Logo
Javatpoint Logo

Java Character isHighSurrogate() Method

The isHighSurrogate(char ch) method of Character class determines whether the given value is high-surrogate code unit, which is also called a leading surrogate code unit.

These values cannot be used to represent the characters by themselves, but they can be used in the representation of supplementary characters in the UTF-16 encoding.

Syntax

Parameter

The above method requires only one parameter:

a.)The character value that needs to be tested.

Return Value

The isHighSurrogate(char ch) method returns a boolean value, i.e., true if the value of the character lies in between MIN_HIGH_SURROGATE and MAX_HIGH_SURROGATE. Otherwise, this method returns false.

Example 1

Test it Now

Output:

The first character is a Unicode high-surrogate code unit: true
The second character is a Unicode high-surrogate code unit: false
The third character is a Unicode high-surrogate code unit: false

Example 2

Test it Now

Output:

The character 'Z' is a Unicode high-surrogate code unit: false
The character 'z' is a Unicode high-surrogate code unit: false

Next TopicJava Character




Please Share

facebook twitter google plus pinterest