3. Values and Data Types

Lesson 1

Java Character Set

Character Set

Character set is a set of valid characters that a language can recognize. A character represents a letter, digit or any other symbol.
E.g.: A to Z, a to z, 0 to 9 and special characters such as ? ! ; :, . > < = + * etc.

Computer Character Sets

There are two computer character sets. They are ASCII and Unicode.

ASCII

ASCII is the basic computer character code set. It stands for American Standard Code for Information Interchange. There are 256 ASCII characters. Each character has an integer value. These are known as ASCII values. The languages C++, VB etc. use ASCII character set. Java uses Unicode character set.

Important ASCII Characters and Their ASCII Values

A 65 B 66 Z 90
a 97 b 98 z 122
0 48 1 49 9 57
space 32

Other numeric values are for special characters and some symbols.

Write output:

int a='A';
System.out.println(a);

char b=97;
System.out.println(b);

Unicode

Unicode is a two byte character code set that has characters representing alphabets in almost all human languages around the world including English, Chinese, Hindi, Malayalam etc. Java uses Unicode character set.

Description and Examples

There are 65536 characters in Unicode character set..

Unicode characters are written in Java using '\u' using four digits.
Value of A is '\u0041' and a is '\u0061'.

Write output:

char a='\u0041';
System.out.println(a);

char b='\u0061';
System.out.println(b);