The amount of constants that will not be modified while the program is running.
Use the final keyword in Java to decorate a constant declaration in a way that is similar to a variable
Finaldouble PI = 3.1415927;
Although constant names can also be lowercase, uppercase letters are usually used to denote constants for easy identification.
Literals can be assigned to variables of any built-in type. For example
byte a = 68; char a = ' a '
byte, int, long, and short can all be represented in decimal, 16-binary, and 8-binary ways.
When a constant is used, the prefix 0 represents 8 binary and the prefix 0x represents 16 binary. For example
intdecimal=100; int octal = 0144; int Hexa =0x64;
As in other languages, a string constant of Java is also a sequence of characters that is contained between two quotation marks. The following is an example of a string literal
"Hello World" "Two\nlines" "\" This is in Quotes\ ""
Both string constants and character constants can contain any Unicode characters. For example
char a = ' \u0001 '; String a = "\u0001";
The Java language supports some special sequences of escape characters.
symbols |
character meaning |
\ n |
Line Break (0x0a) |
\ r |
Enter (0x0d) |
\f |
Page Break (0x0c) |
\b |
BACKSPACE (0x08) |
\s |
Space (0x20) |
\ t |
Tabs |
\" |
Double quotes |
\‘ |
Single quotation marks |
\\ |
Back slash |
\ddd |
octal character (DDD) |
\uxxxx |
16 Binary Unicode characters (xxxx)
|
Technology sharing: www.kaige123.com
This article is from the "11247808" blog, please be sure to keep this source http://11257808.blog.51cto.com/11247808/1868956
Java built-in data types