Java Characters (char)
✅ Java Characters (char)
In Java, the char data type is used to store a single character.
It can be a letter, digit, or special symbol and is enclosed in single quotes ' '.
Characteristics of char
| Feature | Description |
|---|---|
| Size | 2 bytes (16 bits) |
| Values | Any single character, Unicode supported |
| Example | 'A', '9', '%', 'क' |
| Default Value | '\u0000' |
📌 Example: Simple char Variable
Unicode Characters
Java char supports Unicode, which allows international characters:
Character Operations
char can be used in arithmetic operations because internally it is stored as a number (ASCII/Unicode).
char in Conditions
✔ Example Program
Output:
🎯 Summary
charstores single characters.Enclosed in single quotes
' '.Supports Unicode characters.
Can be used in arithmetic and conditions.
