Characters

A single character is represented in Java with the char primitive. The Unicode char occupies 16 bits or 2 bytes, stores a - z, A - Z, 0 - 9, and numerous other characters including those on your keyboard, and characters in languages such as Hebrew, Korean, Arabic, and other doublebyte characters.

char

The char stores 0 to 216-1 or 0 to 65,535

Default value is '\u0000', which is null in Unicode

You can write Unicode char values using a \u and the code number that represents the desired character. Here are some examples of Unicode values.

 '\u0030' is 0 '\u0039' is 9 '\u0041' is A '\u005A' is Z '\u0061' is a '\u007A' is z '\u000A' is LF (line feed will cause a compiler error) '\u000D' is CR (carriage return - will cause compiler error) ...

Get Java Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.