Java Character getName() Method

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

Definition

In Java, Character.getName(codePoint) returns the official Unicode name of a character as an uppercase String. For 'A' it returns "LATIN CAPITAL LETTER A"; for U+1F600 it returns "GRINNING FACE".

Names are a safe way to describe characters in logs and error messages: they are plain ASCII, so they print correctly on any console, even when the character itself would not.

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

Unicode version.

The answer comes from the Unicode Character Database built into your JDK, and each Java release follows a specific Unicode version (Java 8, for example, uses Unicode 6.2). The characters used on this page have had the same properties for many Unicode versions, so the examples print the same result on any current JDK.

Syntax

Pass an int code point; a char is widened automatically.

Java
Character.getName('A');        // "LATIN CAPITAL LETTER A"
Character.getName(0x1F600);    // "GRINNING FACE"
Character.getName(0x10FFFF);   // null, nothing is assigned there
Character.getName(0x110000);   // throws IllegalArgumentException
CallWhat it does
Character.getName(c)Name of a char.
Character.getName(s.codePointAt(i))Name of the character at index i, emoji included.
name != null ? name : "unassigned"Handle unassigned code points.

One overload, getName(int codePoint), added in Java 7. The reverse lookup, codePointOf(name), was added in Java 9.

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

Parameters

ParameterDescription
codePoint (int)A valid code point, 0 to 0x10FFFF.

Return Value

Return ValueDescription
StringThe Unicode name in uppercase.
nullThe code point is unassigned.

Compare with Similar Methods

Related methods:

MethodHow it differs
codePointOf(name)The reverse: name to code point (Java 9+).
getType(cp)The category instead of the name.
isDefined(cp)Whether a code point is assigned at all.

Java Examples

Example 1 — The Unicode Names of Seven Characters

Print the names of ASCII chars, an accented letter, and an emoji. The output is plain ASCII.

Java
public class CharacterGetNameBasic {
    public static void main(String[] args) {
        int[] cps = {'A', 'a', '7', ' ', '$', 0x00E9, 0x1F600};
        for (int cp : cps) {
            System.out.println("U+" + Integer.toHexString(cp) + " " + Character.getName(cp));
        }
    }
}

How It Works

  1. chars in an int array. Char literals such as 'A' widen to their codes, so the array mixes chars and hex code points freely.
  2. Descriptive names. The accented letter is LATIN SMALL LETTER E WITH ACUTE, which describes it exactly without printing it.
  3. Emoji have names too. U+1F600 is GRINNING FACE, even though the character needs two chars in a String.

Example 2 — null for Unassigned, an Exception for Invalid

Ask for the name of a noncharacter, then for two values that are not code points at all.

Java
public class CharacterGetNameMissing {
    public static void main(String[] args) {
        String name = Character.getName(0x10FFFF);
        System.out.println("U+10FFFF: " + (name == null ? "null (unassigned)" : name));
        int[] bad = {0x110000, -1};
        for (int cp : bad) {
            try {
                Character.getName(cp);
            } catch (IllegalArgumentException e) {
                System.out.println(cp + ": IllegalArgumentException");
            }
        }
    }
}

How It Works

  1. A valid but empty slot. U+10FFFF is a permanent noncharacter: a legal code point with no character, so the result is null.
  2. Check before use. Calling a method on the null result would throw, so the code tests name == null first.
  3. Not a code point. 0x110000 (1114112) is one past the maximum and -1 is negative; both throw IllegalArgumentException.

Example 3 — Describe Every Character of a String by Name

Walk a string by code point and print each name, including one for an emoji.

Java
public class CharacterGetNameDescribe {
    public static void main(String[] args) {
        String s = "x=\uD83D\uDC4D";
        int i = 0;
        while (i < s.length()) {
            int cp = s.codePointAt(i);
            System.out.println(i + ": " + Character.getName(cp));
            i += Character.charCount(cp);
        }
    }
}

How It Works

  1. One name per character. The loop asks for the name of each code point, not each char, so the emoji gets one line.
  2. Indexes jump. After the thumbs-up at index 2, charCount adds 2 and the loop ends at length 4.
  3. Readable logs. Printing names instead of the characters keeps the output ASCII-only and makes invisible or look-alike chars obvious.

Frequently Asked Questions

The Unicode name of the code point in uppercase, for example "LATIN CAPITAL LETTER A", or null if the code point is unassigned.
Java 7.
It throws IllegalArgumentException for values below 0 or above 0x10FFFF.
Yes, on Java 9 and newer with Character.codePointOf(name).
Many CJK ideographs have no individual name in the Unicode data, so Java combines the block name and the code point in hex.

Next: getNumericValue()

Get the Unicode numeric value of a character, such as 50 for the Roman numeral L.

getNumericValue() 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.

10 people found this page helpful