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

FeatureDescription
Size2 bytes (16 bits)
ValuesAny 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:

Letter: J
Number: 7
Special Character: @

🎯 Summary

  • char stores single characters.

  • Enclosed in single quotes ' '.

  • Supports Unicode characters.

  • Can be used in arithmetic and conditions.

You may also like...