Java Character isIdentifierIgnorable() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
java.lang.Character

Definition

In Java, Character.isIdentifierIgnorable(ch) returns true for characters that may appear inside an identifier but should be ignored. They are invisible: non-whitespace control characters and format characters.

Exactly these characters are ignorable: 0x00 to 0x08, 0x0E to 0x1B, 0x7F to 0x9F, and every character in the FORMAT category, such as U+00AD SOFT HYPHEN, U+200B ZERO WIDTH SPACE, and U+FEFF (the byte order mark).

A static method of java.lang.Character (Java 1.1+): call it on the class, as in Character.isIdentifierIgnorable(...); you do not need a Character object. No import is needed, because java.lang is always available. The int codePoint overload was added in Java 5.

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 a char, or an int code point.

Java
Character.isIdentifierIgnorable('\u0000');  // true, control in 0x00-0x08
Character.isIdentifierIgnorable('\t');      // false, tab is whitespace
Character.isIdentifierIgnorable('\u007F');  // true, DELETE
Character.isIdentifierIgnorable('\u200B');  // true, FORMAT: zero width space
Character.isIdentifierIgnorable('a');       // false
CallWhat it does
if (!Character.isIdentifierIgnorable(c)) sb.append(c);Strip invisible chars before comparing names.
Character.isIdentifierIgnorable(s.charAt(i))Detect a hidden char in user input.
Character.getType(c) == Character.FORMATThe format part of the rule on its own.

Two overloads: isIdentifierIgnorable(char ch) since Java 1.1 and isIdentifierIgnorable(int codePoint) since Java 5.

Library declarations
Java
// java.lang.Character
public static boolean isIdentifierIgnorable(char ch)        // Java 1.1
public static boolean isIdentifierIgnorable(int codePoint)  // Java 5

Parameters

ParameterDescription
ch (char)The character to test.
codePoint (int)A Unicode code point; invalid values return false.

Return Value

Return ValueDescription
trueOne of the listed control ranges, or a FORMAT character.
falseEverything else, including tab, newline, and 0x1C to 0x1F.

Compare with Similar Methods

Related checks:

MethodHow it differs
isISOControl(ch)All controls, 0x00 to 0x1F and 0x7F to 0x9F, but no FORMAT chars.
isJavaIdentifierPart(ch)Returns true for every ignorable char.
getType(ch)Reports FORMAT (16) or CONTROL (15).

Java Examples

Example 1 — Which Control and Format Characters Are Ignorable

Test chars at the edges of each range, a tab, the soft hyphen, and a letter. Everything is printed in hex.

Java
public class CharacterIsIdentifierIgnorableTable {
    public static void main(String[] args) {
        char[] chars = {'\u0000', '\u0008', '\t', '\u001B', '\u001C', '\u007F', '\u00AD', 'a'};
        for (char c : chars) {
            System.out.println("0x" + Integer.toHexString(c) + " ignorable=" + Character.isIdentifierIgnorable(c));
        }
    }
}

How It Works

  1. The first two ranges. 0x00 and 0x08 are in 0x00 to 0x08; 0x1B (ESCAPE) is the last char of 0x0E to 0x1B.
  2. Whitespace controls are excluded. Tab (0x09) and 0x1C, a separator Java treats as whitespace, return false.
  3. DELETE and the soft hyphen. 0x7F starts the third range, and U+00AD SOFT HYPHEN is a FORMAT character, so both are ignorable.

Example 2 — Remove Invisible Characters Before Comparing Names

Two names look like userName, but one hides a zero width space and the other starts with a byte order mark.

Java
public class CharacterIsIdentifierIgnorableStrip {
    static String strip(String s) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (!Character.isIdentifierIgnorable(c)) sb.append(c);
        }
        return sb.toString();
    }

    public static void main(String[] args) {
        String a = "user\u200BName";
        String b = "\uFEFFuserName";
        System.out.println("lengths: " + a.length() + " " + b.length());
        System.out.println("raw equal: " + a.equals(b));
        System.out.println("stripped equal: " + strip(a).equals(strip(b)));
        System.out.println("stripped: " + strip(a));
    }
}

How It Works

  1. Two hidden chars. U+200B sits in the middle of a, U+FEFF at the start of b; both strings have 9 chars instead of 8.
  2. Different as Strings. equals compares every char, so the raw values do not match.
  3. Same after stripping. Both are FORMAT characters, so strip removes them and the results are both userName.

Example 3 — Count the Ignorable Characters from 0x00 to 0xFF

Split the ignorable chars in the first 256 code points into controls and format chars.

Java
public class CharacterIsIdentifierIgnorableCount {
    public static void main(String[] args) {
        int control = 0, format = 0;
        for (int i = 0; i <= 0xFF; i++) {
            char c = (char) i;
            if (Character.isIdentifierIgnorable(c)) {
                if (Character.getType(c) == Character.CONTROL) control++;
                else if (Character.getType(c) == Character.FORMAT) format++;
            }
        }
        System.out.println("control=" + control + " format=" + format + " total=" + (control + format));
    }
}

How It Works

  1. Three control ranges. 0x00 to 0x08 has 9 chars, 0x0E to 0x1B has 14, and 0x7F to 0x9F has 33: 56 controls in total.
  2. One format char. U+00AD SOFT HYPHEN is the only FORMAT character below 0x100.
  3. getType tells them apart. Comparing with Character.CONTROL and Character.FORMAT shows which part of the rule matched.

Frequently Asked Questions

The character may appear in an identifier, but it is ignored: the Java compiler treats names that differ only by such characters as the same name.
0x00-0x08, 0x0E-0x1B, 0x7F-0x9F, and every character in the FORMAT category, such as U+00AD, U+200B, and U+FEFF.
No. 0x09 to 0x0D and 0x1C to 0x1F are whitespace in Java, so isIdentifierIgnorable returns false for them.
No. isISOControl covers all control characters but no format characters; isIdentifierIgnorable skips the whitespace controls but includes FORMAT characters.
To strip invisible characters such as zero width spaces or byte order marks from names, keys, or user input before comparing them.

Next: isIdeographic()

Check whether a code point is a CJK ideograph, such as a Chinese character (Java 7+).

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

11 people found this page helpful