Java Character highSurrogate() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Java 7+

Definition

In Java, Character.highSurrogate(codePoint) returns the high surrogate: the first of the two chars that encode a supplementary code point in UTF-16. For the emoji U+1F600 it returns '\uD83D'.

The high surrogate carries the upper 10 bits of codePoint - 0x10000, added to 0xD800. Its partner, lowSurrogate(), carries the lower 10 bits.

A static method of java.lang.Character (Java 7+): call it on the class, as in Character.highSurrogate(...); you do not need a Character object. No import is needed, because java.lang is always available.

Syntax

Pass a supplementary code point (0x10000 to 0x10FFFF).

Java
char a = Character.highSurrogate(0x1F600);   // '\uD83D'
char b = Character.highSurrogate(0x10000);   // '\uD800', the first high surrogate
char c = Character.highSurrogate(0x10FFFF);  // '\uDBFF', the last one
// Character.highSurrogate('A')              // unspecified result, do not do this
CallWhat it does
Character.highSurrogate(cp)First char of the pair.
Character.lowSurrogate(cp)Second char of the pair.
(char) (((cp - 0x10000) >> 10) + 0xD800)The same calculation by hand, for Java 6.

One overload, highSurrogate(int codePoint), added in Java 7. For both halves at once, toChars(cp) works on Java 5 and newer.

Library declarations
Java
// java.lang.Character (since Java 7)
public static char highSurrogate(int codePoint)

Parameters

ParameterDescription
codePoint (int)A supplementary code point.

Return Value

Return ValueDescription
charA high surrogate from 0xD800 to 0xDBFF when the input is supplementary.

Compare with Similar Methods

Ways to get the UTF-16 form of a code point:

MethodHow it differs
lowSurrogate(cp)The second half (Java 7+).
toChars(cp)Returns 1 or 2 chars for any valid code point; throws for invalid ones.
toCodePoint(high, low)The reverse direction.

Java Examples

Example 1 — High Surrogates for Four Supplementary Code Points

Print the high surrogate in hex for the first and last supplementary code points, an emoji, and a music symbol.

Java
public class CharacterHighSurrogateValues {
    public static void main(String[] args) {
        int[] cps = {0x10000, 0x1F600, 0x1D11E, 0x10FFFF};
        for (int cp : cps) {
            System.out.println("U+" + Integer.toHexString(cp) + " high=0x"
                    + Integer.toHexString(Character.highSurrogate(cp)));
        }
    }
}

How It Works

  1. The range ends. The first supplementary code point maps to 0xD800 and the last to 0xDBFF, the two ends of the high surrogate range.
  2. Upper bits only. U+1F600 minus 0x10000 is 0xF600; its upper 10 bits are 0x3D, and 0xD800 + 0x3D = 0xD83D.
  3. A char printed as hex. Integer.toHexString widens the returned char to int, so no surrogate is ever sent to the console.

Example 2 — highSurrogate vs the Formula Written by Hand

Compute the high surrogate yourself and compare it with the library for several emoji.

Java
public class CharacterHighSurrogateFormula {
    public static void main(String[] args) {
        int[] cps = {0x1F44D, 0x1F680, 0x20000};
        for (int cp : cps) {
            char byHand = (char) (((cp - 0x10000) >> 10) + 0xD800);
            char byMethod = Character.highSurrogate(cp);
            System.out.println("0x" + Integer.toHexString(cp) + ": 0x" + Integer.toHexString(byMethod)
                    + " same=" + (byHand == byMethod));
        }
    }
}

How It Works

  1. Subtract, shift, add. Subtract 0x10000, keep the top 10 bits with >> 10, then add 0xD800.
  2. Neighbours share a high half. THUMBS UP (U+1F44D) and ROCKET (U+1F680) both start with 0xD83D, because they lie in the same block of 1024 code points.
  3. A CJK example. U+20000 is the start of CJK Extension B; (0x10000 >> 10) is 0x40, so its high surrogate is 0xD840.

Example 3 — Build an Emoji String from Its Two Halves

Create the two chars with highSurrogate and lowSurrogate and compare with toChars.

Java
public class CharacterHighSurrogateBuild {
    public static void main(String[] args) {
        int cp = 0x1F600;
        if (Character.isSupplementaryCodePoint(cp)) {
            String manual = "" + Character.highSurrogate(cp) + Character.lowSurrogate(cp);
            String library = new String(Character.toChars(cp));
            System.out.println("length=" + manual.length());
            System.out.println("same as toChars: " + manual.equals(library));
            System.out.println("decodes back: " + (manual.codePointAt(0) == cp));
        }
    }
}

How It Works

  1. Guard first. isSupplementaryCodePoint makes sure the halves are meaningful; for a BMP code point the result would be unspecified.
  2. Join two chars into text. Starting with "" turns the + into string concatenation instead of adding the two char values as numbers.
  3. Same as the library. The two-char string equals new String(Character.toChars(cp)), and codePointAt(0) gives back 0x1F600.

Frequently Asked Questions

Java 7. On Java 5 and 6, use Character.toChars(cp)[0] or the formula (char) (((cp - 0x10000) >> 10) + 0xD800).
The result is unspecified: no exception, but the char is meaningless. Check isSupplementaryCodePoint first.
For supplementary input, 0xD800 to 0xDBFF.
Character.toChars(cp) returns a char array of length 2 for supplementary code points: high surrogate first, low surrogate second.
No. They do not throw. Validate the code point yourself, or use toChars, which throws IllegalArgumentException for invalid code points.

Next: isAlphabetic()

Check the Unicode Alphabetic property, a wider test than isLetter (Java 7+).

isAlphabetic() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful