CKTIS / Java
Character — the char wrapper and Unicode operations
Character is an immutable wrapper for primitive char values. It also provides static methods for recognizing letters and converting case, with overloads for char values and int code points.
Version: Java SE 21; repository runtime, production runtime not attested
Syntax
Character boxed = 'a';
boolean letter = Character.isLetter('a');
char upper = Character.toUpperCase('a');
boolean supplementaryLetter = Character.isLetter(0x2F81A);
int upperCodePoint = Character.toUpperCase(0x61);Character wraps one primitive char value in an immutable object. The assignment Character boxed = 'a'; uses autoboxing; char ch = boxed; performs unboxing. Static methods do not require creating an object.
A char is a 16-bit UTF-16 code unit, not necessarily a complete Unicode character. Supplementary characters outside the BMP require a surrogate pair. Overloads accepting int handle full code points; a Character wrapper still stores only one char.
Character.isLetter returns a boolean by checking Unicode letter categories, not just ASCII ranges. Character.toUpperCase returns the uppercase equivalent or the unchanged argument: a char input produces a char, and an int input produces an int.
Character.toUpperCase cannot perform locale-sensitive, context-sensitive, or one-to-many mappings. For those text transformations, use String.toUpperCase methods with an appropriately chosen locale.
Examples
public class Main {
public static void main(String[] args) {
Character boxed = 'a';
char ch = boxed;
System.out.println(Character.isLetter(ch));
System.out.println(Character.toUpperCase(ch));
System.out.println(Character.isLetter('7'));
System.out.println(Character.isLetter(0x2F81A));
}
}Result
true A false true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.