Java Reference
In-Depth Information
Other encoding schemes include Unicode, which is a more recent development.
Unicode consists of 65,536 characters. To store a Unicode character, you need two
bytes. Java uses the Unicode character set. Therefore, in Java, every character is repre-
sented as a sequence of 16 bits, that is, 2 bytes. In Unicode, the character A is represented
as 0000000001000001 .
The ASCII character set is a subset of Unicode; the first 128 characters of Unicode are the
same as the characters in ASCII. If you are dealing with only the English language, the
ASCII character set is sufficient to write Java programs. The advantage of the Unicode
character set is that symbols from languages other than English can be handled easily.
Evolution of Programming Languages
The most basic computer language, machine language, provides program instructions in
bits. Even though most computers perform the same kinds of operations, the designers of
different CPUs sometimes choose different sets of binary codes to perform those opera-
tions. Therefore, the machine language of one computer is not necessarily the same as the
machine language of another computer. The only consistency among computers is that in
any computer, all data are stored and manipulated as a binary code.
Early computers were programmed in machine language. To see how instructions are
written in machine language, suppose you want to use the equation:
wages = rate hours
to calculate weekly wages. Assume that the memory locations of rate , hours , and
wages are 010001 , 010010 , and 010011 , respectively. Further suppose that the binary
code 100100 stands for load, 100110 stands for multiplication, and 100010 stands for
store. In machine language, you might need the following sequence of instructions to
calculate the weekly wages:
100100 010001
100110 010010
100010 010011
To represent the weekly wages equation in machine language, the programmer had to
remember the machine language codes for various operations. Also, to manipulate data,
the programmer had to remember the locations of the data in main memory. Remem-
bering specific codes made programming difficult and error prone.
Assembly languages were developed to make the programmer's job easier. In assembly
language, an instruction is an easy-to-remember form called a mnemonic. Table 1-2
shows some examples of
instructions in assembly language and their corresponding
machine language code.
 
Search WWH ::




Custom Search