> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Java char

The `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

A `char` literal is enclosed in single quotation marks. It can be initialized using a character literal, a Unicode escape sequence, or a direct integer value.

```java theme={"dark"}
char letter = 'A';           // Standard character literal
char unicodeHex = '\u0041';  // Unicode escape sequence (Hexadecimal for 'A')
char numericVal = 65;        // Integer literal (Implicit narrowing conversion to 'A')
```

## Integral Nature and Type Conversion

Because `char` 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`.

```java theme={"dark"}
char base = 'A';             // Integer value 65
int widened = base;          // Implicit widening conversion (widened = 65)

// Arithmetic promotion: 'base + 1' evaluates to an int (66).
// An explicit cast is required to assign it back to a char.
char nextChar = (char) (base + 1); // Results in 'B'
```

## Escape Sequences

Java provides specific escape sequences to represent characters that cannot be typed directly or that have special syntactical meaning within the language.

```java theme={"dark"}
char newline = '\n';         // Line feed (U+000A)
char carriageReturn = '\r';  // Carriage return (U+000D)
char tab = '\t';             // Horizontal tab (U+0009)
char singleQuote = '\'';     // Single quote (U+0027)
char doubleQuote = '\"';     // Double quote (U+0022)
char backslash = '\\';       // Backslash (U+005C)
```

## Surrogate Pairs

Because a `char` 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`).

```java theme={"dark"}
// Representing the supplementary character U+10400 (Deseret Capital Letter Long I)
char highSurrogate = '\uD801';
char lowSurrogate = '\uDC00';

// In a String, this requires two char units:
String supplementaryStr = "\uD801\uDC00"; 
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Java Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
