TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
char data type in Java is a single, 16-bit unsigned primitive data type used to store a Unicode character. Strictly speaking, it represents a single UTF-16 code unit, allowing it to hold any character within the Unicode Basic Multilingual Plane (BMP).
Technical Specifications
- Memory Size: 16 bits (2 bytes)
- Minimum Value:
\u0000(integer value 0) - Maximum Value:
\uffff(integer value 65,535) - Signedness: Unsigned (the only unsigned primitive type in Java)
- Default Value:
\u0000(the null character) - Wrapper Class:
java.lang.Character
Syntax and Initialization
Achar literal is enclosed in single quotation marks. It can be initialized using a character literal, a Unicode escape sequence, or a direct integer value.
Integral Nature and Type Conversion
Becausechar is fundamentally an unsigned numeric type, it participates in standard arithmetic operations and bitwise manipulations. When a char is evaluated in an expression, it undergoes numeric promotion to an int.
Escape Sequences
Java provides specific escape sequences to represent characters that cannot be typed directly or that have special syntactical meaning within the language.Surrogate Pairs
Because achar is strictly 16 bits, it cannot natively represent Unicode supplementary characters (code points above U+FFFF). To represent these characters, Java uses a surrogate pair: two consecutive char values consisting of a high surrogate (\uD800 to \uDBFF) followed by a low surrogate (\uDC00 to \uDFFF).
Master Java with Deep Grasping Methodology!Learn More





