O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required