Page 782 - Introduction to Programming with Java: A Problem Solving Approach
P. 782

                748 Appendix 1 Unicode/ASCII Character Set with Hexadecimal Codes
This Web site contains two one-page charts that categorize the world’s major alphabets, symbols, and punctuation. You can select the alphabet or type of symbol you want and obtain pictures and code numbers for all the characters in that category.
In addition to the \u Unicode escape sequence prefix, there are two other hexadecimal annotations you should know. Sometimes you’ll want to use the hexadecimal form of a literal number in a declaration or mathematical formula, because it might be easier or more self-documenting than the decimal form. To do this, just apply 0x as a prefix to the raw hexadecimal number. For example, to tell the compiler you are writing a hexadecimal number rather than a decimal number, you would write 0x41 to specify the number whose decimal value is 65. If you want to display the hexadecimal form of an integer constant or variable using the printf method, use %x for the number’s placeholder in the format string. If what you are repre- senting is a literal, its form in the data list doesn’t matter. It could be either a decimal or a hexadecimal with the 0x prefix. For example, suppose you want an output like this:
Output:
The hexadecimal value for 10 is a
You could generate it with this code:
System.out.printf("The hexadecimal value for 10 is %x\n", 10);
Notice that the hexadecimal output happens to be a lowercase ‘a.’ Case doesn’t matter.
            Apago PDF Enhancer
 

























































































   780   781   782   783   784