Character.isHighSurrogate() method in Java with examples
The java.lang.Character.isHighSurrogate() is a inbuilt method in java which determines if the given char value is a Unicode high-surrogate code unit (also known as leading-surrogate code unit). Such values do not represent characters by themselves but are used in the representation of supplementary characters in the UTF-16 encoding.
Syntax:
public static boolean isHighSurrogate(char ch)
Parameters: The function accepts a single mandatory parameter ch which specifies the value to be tested.
Return Value: The function returns a boolean value. The value returned is True if the char value is between MIN_HIGH_SURROGATE and MAX_HIGH_SURROGATE inclusive, False otherwise.
Below programs illustrate the Character.isHighSurrogate() method:
Program 1:
// Java program to illustrate the // Character.isHighSurrogate() method import java.lang.*; public class gfg { public static void main(String[] args) { // create 2 char primitives c1, c2 char c1 = '\u0a4f', c2 = '\ud8b4'; // assign isHighSurrogate results of // c1, c2 to boolean primitives bool1, bool2 boolean bool1 = Character.isHighSurrogate(c1); System.out.println("c1 is a Unicode"+ "high-surrogate code unit ? " + bool1); boolean bool2 = Character.isHighSurrogate(c2); System.out.println("c2 is a Unicode"+ "high-surrogate code unit ? " + bool2); } } |
c1 is a Unicodehigh-surrogate code unit ? false c2 is a Unicodehigh-surrogate code unit ? true
Program 2:
// Java program to illustrate the // Character.isHighSurrogate() method import java.lang.*; public class gfg { public static void main(String[] args) { // create 2 char primitives c1, c2 char c1 = '\u0b9f', c2 = '\ud5d5'; // assign isHighSurrogate results of // c1, c2 to boolean primitives bool1, bool2 boolean bool1 = Character.isHighSurrogate(c1); System.out.println("c1 is a Unicode" + "high-surrogate code unit ? " + bool1); boolean bool2 = Character.isHighSurrogate(c2); System.out.println("c2 is a Unicode" + "high-surrogate code unit ? " + bool2); } } |
c1 is a Unicodehigh-surrogate code unit ? false c2 is a Unicodehigh-surrogate code unit ? false
Recommended Posts:
- Java lang.Long.numberOfLeadingZeros() method in Java with Examples
- Java.lang.Short toString() method in Java with Examples
- Java lang.Long.builtcount() method in Java with Examples
- Java lang.Long.reverse() method in Java with Examples
- Java.util.Collections.rotate() Method in Java with Examples
- Java lang.Long.lowestOneBit() method in Java with Examples
- Java lang.Long.highestOneBit() method in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples
- Java lang.Long.numberOfTrailingZeros() method in Java with Examples
- Java lang.Long.byteValue() method in Java with Examples
- Java Clock withZone() method in Java with Examples
- Java Clock tickMinutes() method in Java with Examples
- Java 8 | ArrayDeque removeIf() method in Java with Examples
- Set add() method in Java with Examples
- Map put() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

