Java Character Set

Java Character Set | Characters are the smallest units (elements) of Java language that are used to write Java tokens. These characters are defined by the Unicode character set.

A character set in Java is a set of alphabets, letters, and some special characters that are valid in java programming language.

The first character set used in the computer system was US-ASCII (American Standard Code for Information Interchange (ASCII pronounced as ass-kee)). It is limited to represent only American English.

US-ASCII consists of uppercase and lowercase Latin alphabets, numerals, punctuation, a set of control codes, and a few miscellaneous symbols.

Unicode defines a standardized 16-bit character coding system. It currently supports more than 34,000 defined characters derived from 24 languages from America, Europe, Middle East, Africa, and Asia (including India).

However, we use mostly basic ASCII characters to develop a program that includes letters, digits, and punctuation marks used in normal English.

Java language uses the character sets as the building block to form the basic elements such as identifiers, variables, array, etc in the program. These are as follows:

  • Letters: Both lowercase (a, b, c, d, e, etc. ) and uppercase (A, B, C, D, E, etc.) letters.
  • Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
  • Special symbols: _, (, ), {, }, [, ], +, -, *, /, %, !, &, |, ~, ^, <, =, >, $, #, ?, Comma (,), Dot (.), Colon (:), Semi-colon (;), Single quote (‘), Double quote (“), Back slash (\).
  • White space: Space, Tab, New line.

Unicode represents a standardized and universal character set that can be extended to accommodate additions.

When the program source code file encoding does not support Unicode in Java, we can define Unicode characters as escape sequences by using the notation \uXXXX, where XXXX specifies the character’s 16-bit representation in hexadecimal.

Hope that this tutorial has covered all the basic points related to character set in Java with example. I hope that you will have understood this simple and basic topic.

In the next tutorial, we will learn a set of keywords in Java.
Thanks for reading!!!
Next ⇒ Keywords in Java

⇐ Prev Next ⇒